diff --git a/coder_sniffer/Drupal/Sniffs/Array/DisallowLongArraySyntaxSniff.php b/coder_sniffer/Drupal/Sniffs/Array/DisallowLongArraySyntaxSniff.php deleted file mode 100644 index fe72b444aa2bd018b77b98b6a335dbdcee5b67f4..0000000000000000000000000000000000000000 --- a/coder_sniffer/Drupal/Sniffs/Array/DisallowLongArraySyntaxSniff.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php -/** - * Drupal_Sniffs_Array_DisallowLongArraySyntaxSniff. - * - * @category PHP - * @package PHP_CodeSniffer - * @link http://pear.php.net/package/PHP_CodeSniffer - */ - -/** - * Bans the use of the PHP long array syntax in Drupal 8. - * - * @category PHP - * @package PHP_CodeSniffer - * @link http://pear.php.net/package/PHP_CodeSniffer - */ -class Drupal_Sniffs_Array_DisallowLongArraySyntaxSniff extends Generic_Sniffs_Arrays_DisallowLongArraySyntaxSniff -{ - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * - * @return void|int - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $drupalVersion = DrupalPractice_Project::getCoreVersion($phpcsFile); - if ($drupalVersion !== '8.x') { - // No need to check this file again, mark it as done. - return ($phpcsFile->numTokens + 1); - } - - return parent::process($phpcsFile, $stackPtr); - - }//end process() - - -}//end class diff --git a/coder_sniffer/Drupal/Sniffs/Array/ArraySniff.php b/coder_sniffer/Drupal/Sniffs/Arrays/ArraySniff.php similarity index 92% rename from coder_sniffer/Drupal/Sniffs/Array/ArraySniff.php rename to coder_sniffer/Drupal/Sniffs/Arrays/ArraySniff.php index f9fcd43f40a0e88eb8925d4529d56dfbe15ad64a..e1edb9fb2b9922062d39d8513fad9300885323a7 100644 --- a/coder_sniffer/Drupal/Sniffs/Array/ArraySniff.php +++ b/coder_sniffer/Drupal/Sniffs/Arrays/ArraySniff.php @@ -1,14 +1,20 @@ <?php /** - * Drupal_Sniffs_Array_ArraySniff. + * \Drupal\Sniffs\Arrays\ArraySniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Arrays; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** - * Drupal_Sniffs_Array_ArraySniff. + * ArraySniff. * * Checks if the array's are styled in the Drupal way. * - Comma after the last array element @@ -18,7 +24,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Array_ArraySniff implements PHP_CodeSniffer_Sniff +class ArraySniff implements Sniff { @@ -40,13 +46,13 @@ class Drupal_Sniffs_Array_ArraySniff implements PHP_CodeSniffer_Sniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in + * the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -65,7 +71,7 @@ class Drupal_Sniffs_Array_ArraySniff implements PHP_CodeSniffer_Sniff } $lastItem = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($tokens[$stackPtr][$parenthesis_closer] - 1), $stackPtr, true @@ -83,7 +89,7 @@ class Drupal_Sniffs_Array_ArraySniff implements PHP_CodeSniffer_Sniff if ($tokens[$lastItem]['code'] !== T_COMMA && $isInlineArray === false && $tokens[($lastItem + 1)]['code'] !== T_CLOSE_PARENTHESIS && $tokens[($lastItem + 1)]['code'] !== T_CLOSE_SHORT_ARRAY - && isset(PHP_CodeSniffer_Tokens::$heredocTokens[$tokens[$lastItem]['code']]) === false + && isset(Tokens::$heredocTokens[$tokens[$lastItem]['code']]) === false ) { $data = array($tokens[$lastItem]['content']); $fix = $phpcsFile->addFixableWarning('A comma should follow the last multiline array item. Found: %s', $lastItem, 'CommaLastItem', $data); @@ -146,7 +152,7 @@ class Drupal_Sniffs_Array_ArraySniff implements PHP_CodeSniffer_Sniff $current_line = $tokens[$newLineStart]['line']; while ($current_line >= $tokens[$newLineStart]['line']) { $newLineStart = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($newLineStart + 1), ($tokens[$stackPtr][$parenthesis_closer] + 1), true @@ -215,7 +221,7 @@ class Drupal_Sniffs_Array_ArraySniff implements PHP_CodeSniffer_Sniff $isMultiLineString = $tokens[($newLineStart - 1)]['code'] === T_CONSTANT_ENCAPSED_STRING && substr($tokens[($newLineStart - 1)]['content'], -1) === $phpcsFile->eolChar; // Skip NOWDOC or HEREDOC lines. - $nowDoc = isset(PHP_CodeSniffer_Tokens::$heredocTokens[$tokens[$newLineStart]['code']]); + $nowDoc = isset(Tokens::$heredocTokens[$tokens[$newLineStart]['code']]); if ($innerNesting === false && $isMultiLineString === false && $nowDoc === false) { $error = 'Array indentation error, expected %s spaces but found %s'; $data = array( diff --git a/coder_sniffer/Drupal/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php b/coder_sniffer/Drupal/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php new file mode 100644 index 0000000000000000000000000000000000000000..23808033754766ea3ced6c518d93835f8d114ad0 --- /dev/null +++ b/coder_sniffer/Drupal/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php @@ -0,0 +1,51 @@ +<?php +/** + * \Drupal\Sniffs\Arrays\DisallowLongArraySyntaxSniff. + * + * @category PHP + * @package PHP_CodeSniffer + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +namespace Drupal\Sniffs\Arrays; + +require_once __DIR__.'/../../../DrupalPractice/Project.php'; + +use PHP_CodeSniffer\Files\File; +use DrupalPractice\Project; +use PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff as GenericDisallowLongArraySyntaxSniff; + +/** + * Bans the use of the PHP long array syntax in Drupal 8. + * + * @category PHP + * @package PHP_CodeSniffer + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class DisallowLongArraySyntaxSniff extends GenericDisallowLongArraySyntaxSniff +{ + + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * + * @return void|int + */ + public function process(File $phpcsFile, $stackPtr) + { + $drupalVersion = Project::getCoreVersion($phpcsFile); + if ($drupalVersion !== '8.x') { + // No need to check this file again, mark it as done. + return ($phpcsFile->numTokens + 1); + } + + return parent::process($phpcsFile, $stackPtr); + + }//end process() + + +}//end class diff --git a/coder_sniffer/Drupal/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php b/coder_sniffer/Drupal/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php index 4184ac6b06342093d21ef840dbccc5cf473ab96c..a3780c282d8bc4c8b3c3e4158cd3c9fe2b6ea0d7 100644 --- a/coder_sniffer/Drupal/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php +++ b/coder_sniffer/Drupal/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php @@ -1,22 +1,28 @@ <?php /** - * Drupal_Sniffs_CSS_ClassDefinitionNameSpacingSniff. + * \Drupal\Sniffs\CSS\ClassDefinitionNameSpacingSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\CSS; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Ensure there are no blank lines between the names of classes/IDs. Copied from - * Squiz_Sniffs_CSS_ClassDefinitionNameSpacingSniff because we also check for comma - * separated selectors on their own line. + * \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ClassDefinitionNameSpacingSniff + * because we also check for comma separated selectors on their own line. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_CSS_ClassDefinitionNameSpacingSniff implements PHP_CodeSniffer_Sniff +class ClassDefinitionNameSpacingSniff implements Sniff { /** @@ -42,13 +48,13 @@ class Drupal_Sniffs_CSS_ClassDefinitionNameSpacingSniff implements PHP_CodeSniff /** * Processes the tokens that this sniff is interested in. * - * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. + * @param int $stackPtr The position in the stack where + * the token was found. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -65,7 +71,7 @@ class Drupal_Sniffs_CSS_ClassDefinitionNameSpacingSniff implements PHP_CodeSniff T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET, T_OPEN_TAG => T_OPEN_TAG, ); - $endTokens += PHP_CodeSniffer_Tokens::$commentTokens; + $endTokens += Tokens::$commentTokens; $foundContent = false; $currentLine = $tokens[$stackPtr]['line']; diff --git a/coder_sniffer/Drupal/Sniffs/CSS/ColourDefinitionSniff.php b/coder_sniffer/Drupal/Sniffs/CSS/ColourDefinitionSniff.php index e80021a4fef8e65afbae77c182259ccc7060851b..be8f88898c36a0d3627b80bb4ab2b4965c528c93 100644 --- a/coder_sniffer/Drupal/Sniffs/CSS/ColourDefinitionSniff.php +++ b/coder_sniffer/Drupal/Sniffs/CSS/ColourDefinitionSniff.php @@ -1,14 +1,19 @@ <?php /** - * Drupal_Sniffs_CSS_ColourDefinitionSniff. + * \Drupal\Sniffs\CSS\ColourDefinitionSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\CSS; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** - * Squiz_Sniffs_CSS_ColourDefinitionSniff. + * \Drupal\Sniffs\CSS\ColourDefinitionSniff. * * Ensure colours are defined in lower-case. * @@ -16,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_CSS_ColourDefinitionSniff implements PHP_CodeSniffer_Sniff +class ColourDefinitionSniff implements Sniff { /** @@ -42,13 +47,13 @@ class Drupal_Sniffs_CSS_ColourDefinitionSniff implements PHP_CodeSniffer_Sniff /** * Processes the tokens that this sniff is interested in. * - * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. + * @param int $stackPtr The position in the stack where + * the token was found. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $colour = $tokens[$stackPtr]['content']; diff --git a/coder_sniffer/Drupal/Sniffs/Classes/ClassCreateInstanceSniff.php b/coder_sniffer/Drupal/Sniffs/Classes/ClassCreateInstanceSniff.php index 9476c7d288dea6b02de20e3f7c964d4b3b4f2fb3..bb08722e7eb08beb35e26636b0284181a9cfb168 100644 --- a/coder_sniffer/Drupal/Sniffs/Classes/ClassCreateInstanceSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Classes/ClassCreateInstanceSniff.php @@ -7,6 +7,12 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Classes; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Class create instance Test. * @@ -16,7 +22,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Classes_ClassCreateInstanceSniff implements PHP_CodeSniffer_Sniff +class ClassCreateInstanceSniff implements Sniff { @@ -35,13 +41,13 @@ class Drupal_Sniffs_Classes_ClassCreateInstanceSniff implements PHP_CodeSniffer_ /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -56,7 +62,7 @@ class Drupal_Sniffs_Classes_ClassCreateInstanceSniff implements PHP_CodeSniffer_ $nextParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($stackPtr + 1), $commaOrColon); if ($nextParenthesis === false) { $error = 'Calling class constructors must always include parentheses'; - $constructor = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true); + $constructor = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true); // We can invoke the fixer if we know this is a static constructor // function call or constructor calls with namespaces, example // "new \DOMDocument;" or constructor with class names in variables @@ -70,7 +76,7 @@ class Drupal_Sniffs_Classes_ClassCreateInstanceSniff implements PHP_CodeSniffer_ $nextConstructorPart = $constructor; while (true) { $nextConstructorPart = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($nextConstructorPart + 1), null, true, diff --git a/coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php b/coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php index d4c49c256e2a56be16eec19c587685462a97fe22..ea63234b7dafe275312b91c92cf665388962cfe6 100644 --- a/coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php @@ -7,6 +7,12 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Classes; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\ClassDeclarationSniff as PSR2ClassDeclarationSniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Class Declaration Test. * @@ -16,7 +22,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Classes_ClassDeclarationSniff extends PSR2_Sniffs_Classes_ClassDeclarationSniff +class ClassDeclarationSniff extends PSR2ClassDeclarationSniff { @@ -39,13 +45,13 @@ class Drupal_Sniffs_Classes_ClassDeclarationSniff extends PSR2_Sniffs_Classes_Cl /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param integer $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param integer $stackPtr The position of the current token in the + * stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $errorData = array(strtolower($tokens[$stackPtr]['content'])); @@ -122,13 +128,13 @@ class Drupal_Sniffs_Classes_ClassDeclarationSniff extends PSR2_Sniffs_Classes_Cl /** * Processes the closing section of a class declaration. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function processClose(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function processClose(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -143,7 +149,7 @@ class Drupal_Sniffs_Classes_ClassDeclarationSniff extends PSR2_Sniffs_Classes_Cl if ($prevContent !== $tokens[$stackPtr]['scope_opener'] && $tokens[$prevContent]['line'] !== ($tokens[$closeBrace]['line'] - 2) // If the class only contains a comment no extra line is needed. - && isset(PHP_CodeSniffer_Tokens::$commentTokens[$tokens[$prevContent]['code']]) === false + && isset(Tokens::$commentTokens[$tokens[$prevContent]['code']]) === false ) { $error = 'The closing brace for the %s must have an empty line before it'; $data = array($tokens[$stackPtr]['content']); diff --git a/coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php b/coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php index ed6088514a593acbb2563e774304a1f688e03e07..46f71ab8e93ff8cbbfb0d06172d5d5be519a45d0 100644 --- a/coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Classes_FullyQualifiedNamespaceSniff. + * \Drupal\Sniffs\Classes\FullyQualifiedNamespaceSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Classes; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that class references do not use FQN but use statements. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Classes_FullyQualifiedNamespaceSniff implements PHP_CodeSniffer_Sniff +class FullyQualifiedNamespaceSniff implements Sniff { @@ -33,18 +38,18 @@ class Drupal_Sniffs_Classes_FullyQualifiedNamespaceSniff implements PHP_CodeSnif /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the - * token was found. - * @param int $stackPtr The position in the PHP_CodeSniffer - * file's token stack where the token - * was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where the + * token was found. + * @param int $stackPtr The position in the PHP_CodeSniffer + * file's token stack where the token + * was found. * * @return void|int Optionally returns a stack pointer. The sniff will not be * called again on the current file until the returned stack * pointer is reached. Return $phpcsFile->numTokens + 1 to skip * the rest of the file. */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/Classes/InterfaceNameSniff.php b/coder_sniffer/Drupal/Sniffs/Classes/InterfaceNameSniff.php index 2852da2d778ef77a3cd19d72de0bde683736509e..156ea060b6cdbb15e94fa58613be875e2db3bc2a 100644 --- a/coder_sniffer/Drupal/Sniffs/Classes/InterfaceNameSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Classes/InterfaceNameSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Classes_InterfaceNameSniff. + * \Drupal\Sniffs\Classes\InterfaceNameSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Classes; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that interface names end with "Interface". * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Classes_InterfaceNameSniff implements PHP_CodeSniffer_Sniff +class InterfaceNameSniff implements Sniff { @@ -33,13 +38,13 @@ class Drupal_Sniffs_Classes_InterfaceNameSniff implements PHP_CodeSniffer_Sniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in + * the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $namePtr = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); diff --git a/coder_sniffer/Drupal/Sniffs/Classes/PropertyDeclarationSniff.php b/coder_sniffer/Drupal/Sniffs/Classes/PropertyDeclarationSniff.php index b672329679567c2deb6df151f7c5b881d73d9add..ffd231d3d9e2167b01f59c6b2f82a8e8cf05fa2c 100644 --- a/coder_sniffer/Drupal/Sniffs/Classes/PropertyDeclarationSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Classes/PropertyDeclarationSniff.php @@ -7,27 +7,34 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Classes; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\AbstractVariableSniff; +use PHP_CodeSniffer\Util\Tokens; + /** - * Laregely copied from PSR2_Sniffs_Classes_PropertyDeclarationSniff to have a fixer + * Laregely copied from + * \PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\PropertyDeclarationSniff to have a fixer * for the var keyword. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Classes_PropertyDeclarationSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff +class PropertyDeclarationSniff extends AbstractVariableSniff { /** * Processes the function tokens within the class. * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. * * @return void */ - protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function processMemberVar(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -40,7 +47,7 @@ class Drupal_Sniffs_Classes_PropertyDeclarationSniff extends PHP_CodeSniffer_Sta // Detect multiple properties defined at the same time. Throw an error // for this, but also only process the first property in the list so we don't // repeat errors. - $find = PHP_CodeSniffer_Tokens::$scopeModifiers; + $find = Tokens::$scopeModifiers; $find = array_merge($find, array(T_VARIABLE, T_VAR, T_SEMICOLON)); $prev = $phpcsFile->findPrevious($find, ($stackPtr - 1)); if ($tokens[$prev]['code'] === T_VARIABLE) { @@ -61,7 +68,7 @@ class Drupal_Sniffs_Classes_PropertyDeclarationSniff extends PHP_CodeSniffer_Sta $phpcsFile->addError($error, $stackPtr, 'Multiple'); } - $modifier = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, $stackPtr); + $modifier = $phpcsFile->findPrevious(Tokens::$scopeModifiers, $stackPtr); if (($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line'])) { $error = 'Visibility must be declared on property "%s"'; $data = array($tokens[$stackPtr]['content']); @@ -74,12 +81,12 @@ class Drupal_Sniffs_Classes_PropertyDeclarationSniff extends PHP_CodeSniffer_Sta /** * Processes normal variables. * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. * * @return void */ - protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function processVariable(File $phpcsFile, $stackPtr) { /* We don't care about normal variables. @@ -91,12 +98,12 @@ class Drupal_Sniffs_Classes_PropertyDeclarationSniff extends PHP_CodeSniffer_Sta /** * Processes variables in double quoted strings. * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. * * @return void */ - protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function processVariableInString(File $phpcsFile, $stackPtr) { /* We don't care about normal variables. diff --git a/coder_sniffer/Drupal/Sniffs/Classes/UnusedUseStatementSniff.php b/coder_sniffer/Drupal/Sniffs/Classes/UnusedUseStatementSniff.php index 4825e228ffb8723466d9c521832f7c0aaddbf456..d506a59c042738c86bf704f2c69680a6e7529142 100644 --- a/coder_sniffer/Drupal/Sniffs/Classes/UnusedUseStatementSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Classes/UnusedUseStatementSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_Classes_UnusedUseStatementSniff. + * \Drupal\Sniffs\Classes\UnusedUseStatementSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Classes; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks for "use" statements that are not needed in a file. * @@ -14,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Classes_UnusedUseStatementSniff implements PHP_CodeSniffer_Sniff +class UnusedUseStatementSniff implements Sniff { @@ -33,13 +39,13 @@ class Drupal_Sniffs_Classes_UnusedUseStatementSniff implements PHP_CodeSniffer_S /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in + * the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -55,7 +61,7 @@ class Drupal_Sniffs_Classes_UnusedUseStatementSniff implements PHP_CodeSniffer_S } $classPtr = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($semiColon - 1), null, true @@ -117,7 +123,7 @@ class Drupal_Sniffs_Classes_UnusedUseStatementSniff implements PHP_CodeSniffer_S } $beforeUsage = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($classUsed - 1), null, true diff --git a/coder_sniffer/Drupal/Sniffs/Classes/UseLeadingBackslashSniff.php b/coder_sniffer/Drupal/Sniffs/Classes/UseLeadingBackslashSniff.php index bad21c08b4dea7b955374a9008bb23f457f14ed3..9bc894a0d1ab0ce45e9dea5dad00cb6bd8aff33a 100644 --- a/coder_sniffer/Drupal/Sniffs/Classes/UseLeadingBackslashSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Classes/UseLeadingBackslashSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_Classes_UseLeadingBackslashSniff. + * \Drupal\Sniffs\Classes\UseLeadingBackslashSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Classes; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Use statements to import classes must not begin with "\". * @@ -14,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Classes_UseLeadingBackslashSniff implements PHP_CodeSniffer_Sniff +class UseLeadingBackslashSniff implements Sniff { @@ -33,13 +39,13 @@ class Drupal_Sniffs_Classes_UseLeadingBackslashSniff implements PHP_CodeSniffer_ /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in + * the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -49,7 +55,7 @@ class Drupal_Sniffs_Classes_UseLeadingBackslashSniff implements PHP_CodeSniffer_ } $startPtr = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($stackPtr + 1), null, true diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.php index 6cf50484fced9c627714b0286ad6914f318696d6..68bacb1b1be6ab41c954c95ea18e4c1e9320f588 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.php @@ -7,9 +7,15 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks that comment doc blocks exist on classes, interfaces and traits. Largely - * copied from Squiz_Sniffs_Commenting_ClassCommentSniff. + * copied from PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\ClassCommentSniff. * * @category PHP * @package PHP_CodeSniffer @@ -19,7 +25,7 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Commenting_ClassCommentSniff implements PHP_CodeSniffer_Sniff +class ClassCommentSniff implements Sniff { @@ -42,16 +48,16 @@ class Drupal_Sniffs_Commenting_ClassCommentSniff implements PHP_CodeSniffer_Snif /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $find = PHP_CodeSniffer_Tokens::$methodPrefixes; + $find = Tokens::$methodPrefixes; $find[] = T_WHITESPACE; $name = $tokens[$stackPtr]['content']; diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/DataTypeNamespaceSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/DataTypeNamespaceSniff.php index 6638a519c7577a4de1818376f42f55c2b8f71fe0..6778d5ce2de3a2f1af68f6e2cd118b0f820f6a4b 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/DataTypeNamespaceSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/DataTypeNamespaceSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_Commenting_DataTypeNamespaceSniff. + * \Drupal\Sniffs\Commenting\DataTypeNamespaceSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks that data types in param, return, var tags are fully namespaced. * @@ -14,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Commenting_DataTypeNamespaceSniff implements PHP_CodeSniffer_Sniff +class DataTypeNamespaceSniff implements Sniff { @@ -33,13 +39,13 @@ class Drupal_Sniffs_Commenting_DataTypeNamespaceSniff implements PHP_CodeSniffer /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in + * the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -55,7 +61,7 @@ class Drupal_Sniffs_Commenting_DataTypeNamespaceSniff implements PHP_CodeSniffer } $classPtr = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($semiColon - 1), null, true diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentAlignmentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentAlignmentSniff.php index 4703dbe38260ba0c384e182591bc76eb84323b54..167b2def534baabf3af308349d6f735beb0696f2 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentAlignmentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentAlignmentSniff.php @@ -1,14 +1,21 @@ <?php /** - * Drupal_Sniffs_Commenting_EmptyCatchCommentSniff. + * \Drupal\Sniffs\Commenting\DocCommentAlignmentSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** - * Largely copied from Squiz_Sniffs_Commenting_DocCommentAlignmentSniff to also + * Largely copied from + * \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\DocCommentAlignmentSniff to also * handle the "var" keyword. See * https://github.com/squizlabs/PHP_CodeSniffer/pull/1212 * @@ -16,7 +23,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Commenting_DocCommentAlignmentSniff implements PHP_CodeSniffer_Sniff +class DocCommentAlignmentSniff implements Sniff { @@ -35,18 +42,18 @@ class Drupal_Sniffs_Commenting_DocCommentAlignmentSniff implements PHP_CodeSniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); // We are only interested in function/class/interface doc block comments. - $ignore = PHP_CodeSniffer_Tokens::$emptyTokens; + $ignore = Tokens::$emptyTokens; if ($phpcsFile->tokenizerType === 'JS') { $ignore[] = T_EQUAL; $ignore[] = T_STRING; @@ -71,7 +78,7 @@ class Drupal_Sniffs_Commenting_DocCommentAlignmentSniff implements PHP_CodeSniff if (isset($ignore[$tokens[$nextToken]['code']]) === false) { // Could be a file comment. - $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($tokens[$prevToken]['code'] !== T_OPEN_TAG) { return; } diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php index 10fbe8f2c43a9716d0ff800b9e1d132b15f925cb..ecc948a99ef551ae08dfb7dab93a399de63985fd 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php @@ -7,17 +7,23 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Ensures doc blocks follow basic formatting. * - * Largely copied from Generic_Sniffs_Commenting_DocCommentSniff, but Drupal @file - * comments are different. + * Largely copied from + * \PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\DocCommentSniff, + * but Drupal @file comments are different. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Commenting_DocCommentSniff implements PHP_CodeSniffer_Sniff +class DocCommentSniff implements Sniff { /** @@ -46,13 +52,13 @@ class Drupal_Sniffs_Commenting_DocCommentSniff implements PHP_CodeSniffer_Sniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $commentEnd = $phpcsFile->findNext(T_DOC_COMMENT_CLOSE_TAG, ($stackPtr + 1)); diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentStarSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentStarSniff.php index f4a87ae2dd9a9b5d1d4d6334d67243481b32b876..f79108130ea586735def35dbed72b4c0747861b6 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentStarSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentStarSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Commenting_DocCommentStarSniff + * \Drupal\Sniffs\Commenting\DocCommentStarSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that a doc comment block has a doc comment star on every line. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Commenting_DocCommentStarSniff implements PHP_CodeSniffer_Sniff +class DocCommentStarSniff implements Sniff { @@ -33,13 +38,13 @@ class Drupal_Sniffs_Commenting_DocCommentStarSniff implements PHP_CodeSniffer_Sn /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/FileCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/FileCommentSniff.php index 55746bc367e7665f84b361ba90f746eb39cbd94f..2fe5e944943fd544d26a4cbbdcdc89fdf772df78 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/FileCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/FileCommentSniff.php @@ -7,6 +7,11 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Parses and verifies the doc comments for files. * @@ -21,7 +26,7 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff +class FileCommentSniff implements Sniff { @@ -51,13 +56,13 @@ class Drupal_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return int */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $this->currentFile = $phpcsFile; diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php index ed9e14cd4615c17c64a111573c1e58f4d0a49faf..b6806fb8e89264ff4f50d44e6838b1f60c2632aa 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php @@ -7,15 +7,21 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Parses and verifies the doc comments for functions. Largely copied from - * Squiz_Sniffs_Commenting_FunctionCommentSniff. + * PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff +class FunctionCommentSniff implements Sniff { /** @@ -72,20 +78,20 @@ class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $find = PHP_CodeSniffer_Tokens::$methodPrefixes; + $find = Tokens::$methodPrefixes; $find[] = T_WHITESPACE; $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true); - $beforeCommentEnd = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($commentEnd - 1), null, true); + $beforeCommentEnd = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($commentEnd - 1), null, true); if (($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG && $tokens[$commentEnd]['code'] !== T_COMMENT) || ($beforeCommentEnd !== false @@ -162,14 +168,14 @@ class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S /** * Process the return comment of this function comment. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * @param int $commentStart The position in the stack where the comment started. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * @param int $commentStart The position in the stack where the comment started. * * @return void */ - protected function processReturn(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $commentStart) + protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) { $tokens = $phpcsFile->getTokens(); @@ -365,14 +371,14 @@ class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S /** * Process any throw tags that this function comment has. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * @param int $commentStart The position in the stack where the comment started. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * @param int $commentStart The position in the stack where the comment started. * * @return void */ - protected function processThrows(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $commentStart) + protected function processThrows(File $phpcsFile, $stackPtr, $commentStart) { $tokens = $phpcsFile->getTokens(); @@ -445,14 +451,14 @@ class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S /** * Process the function parameter comments. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * @param int $commentStart The position in the stack where the comment started. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * @param int $commentStart The position in the stack where the comment started. * * @return void */ - protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $commentStart) + protected function processParams(File $phpcsFile, $stackPtr, $commentStart) { $tokens = $phpcsFile->getTokens(); @@ -568,6 +574,7 @@ class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S $phpcsFile->addError($error, $tag, 'MissingParamComment'); $commentLines[] = array('comment' => ''); }//end if + $variableArguments = false; // Allow the "..." @param doc for a variable number of parameters. // This could happen with type defined as @param array ... or @@ -872,14 +879,14 @@ class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S /** * Process the function "see" comments. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * @param int $commentStart The position in the stack where the comment started. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * @param int $commentStart The position in the stack where the comment started. * * @return void */ - protected function processSees(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $commentStart) + protected function processSees(File $phpcsFile, $stackPtr, $commentStart) { $tokens = $phpcsFile->getTokens(); foreach ($tokens[$commentStart]['comment_tags'] as $tag) { @@ -938,14 +945,14 @@ class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S /** * Checks if a used type hint is an alias defined by a "use" statement. * - * @param string $typeHint The type hint used. - * @param string $suggestedTypeHint The fully qualified type to - * check against. - * @param PHP_CodeSniffer_File $phpcsFile The file being checked. + * @param string $typeHint The type hint used. + * @param string $suggestedTypeHint The fully qualified type to + * check against. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being checked. * * @return boolean */ - protected function isAliasedType($typeHint, $suggestedTypeHint, PHP_CodeSniffer_File $phpcsFile) + protected function isAliasedType($typeHint, $suggestedTypeHint, File $phpcsFile) { $tokens = $phpcsFile->getTokens(); @@ -964,7 +971,7 @@ class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S // Now comes the original class name, possibly with namespace // backslashes. - $originalClass = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($usePtr + 1), null, true); + $originalClass = $phpcsFile->findNext(Tokens::$emptyTokens, ($usePtr + 1), null, true); if ($originalClass === false || ($tokens[$originalClass]['code'] !== T_STRING && $tokens[$originalClass]['code'] !== T_NS_SEPARATOR) ) { @@ -982,13 +989,13 @@ class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S } // Now comes the "as" keyword signaling an alias name for the class. - $asPtr = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($originalClass + 1), null, true); + $asPtr = $phpcsFile->findNext(Tokens::$emptyTokens, ($originalClass + 1), null, true); if ($asPtr === false || $tokens[$asPtr]['code'] !== T_AS) { continue; } // Now comes the name the class is aliased to. - $aliasPtr = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($asPtr + 1), null, true); + $aliasPtr = $phpcsFile->findNext(Tokens::$emptyTokens, ($asPtr + 1), null, true); if ($aliasPtr === false || $tokens[$aliasPtr]['code'] !== T_STRING || $tokens[$aliasPtr]['content'] !== $typeHint ) { diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php index f2fa4f01d65c0ed2283bdd9919f1801b5779d1d4..84f95ff2bb966923b3b5b2d3ebc0cbbc13066999 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/HookCommentSniff.php @@ -7,6 +7,12 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Ensures hook comments on function are correct. * @@ -14,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Commenting_HookCommentSniff implements PHP_CodeSniffer_Sniff +class HookCommentSniff implements Sniff { @@ -33,16 +39,16 @@ class Drupal_Sniffs_Commenting_HookCommentSniff implements PHP_CodeSniffer_Sniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - $find = PHP_CodeSniffer_Tokens::$methodPrefixes; + $find = Tokens::$methodPrefixes; $find[] = T_WHITESPACE; $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true); @@ -89,7 +95,7 @@ class Drupal_Sniffs_Commenting_HookCommentSniff implements PHP_CodeSniffer_Sniff if (strstr($matches[0], 'Implements ') === false || strstr($matches[0], 'Implements of') !== false || preg_match('/ (drush_)?hook_[a-zA-Z0-9_]+\(\)( for .+)?\.$/', $matches[0]) !== 1 ) { - $phpcsFile->addWarning('Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar() for xyz-bar.html.twig.", "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block templates."', $short); + $phpcsFile->addWarning('Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar() for xyz-bar.html.twig.", "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block templates."', $short, 'HookCommentFormat'); } else { // Check that a hook implementation does not duplicate @param and // @return documentation. diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php index 32da8dd918b7124e3273b4aef5eecf5c86601efc..cbdfc708bdd415b5692be03a6ba37aa396ccb4f1 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/InlineCommentSniff.php @@ -1,24 +1,31 @@ <?php /** - * PHP_CodeSniffer_Sniffs_Drupal_Commenting_InlineCommentSniff. + * \Drupal\Sniffs\Commenting\InlineCommentSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** - * PHP_CodeSniffer_Sniffs_Drupal_Commenting_InlineCommentSniff. + * \Drupal\Sniffs\Commenting\InlineCommentSniff. * * Checks that no perl-style comments are used. Checks that inline comments ("//") * have a space after //, start capitalized and end with proper punctuation. - * Largely copied from Squiz_Sniffs_Commenting_InlineCommentSniff. + * Largely copied from + * \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\InlineCommentSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sniff +class InlineCommentSniff implements Sniff { /** @@ -50,13 +57,13 @@ class Drupal_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sni /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -65,7 +72,7 @@ class Drupal_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sni // not allowed. if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT_OPEN_TAG) { $nextToken = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($stackPtr + 1), null, true @@ -99,7 +106,7 @@ class Drupal_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sni if ($phpcsFile->tokenizerType === 'JS') { // We allow block comments if a function or object // is being assigned to a variable. - $ignore = PHP_CodeSniffer_Tokens::$emptyTokens; + $ignore = Tokens::$emptyTokens; $ignore[] = T_EQUAL; $ignore[] = T_STRING; $ignore[] = T_OBJECT_OPERATOR; @@ -114,7 +121,7 @@ class Drupal_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sni } $prevToken = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($stackPtr - 1), null, true @@ -322,14 +329,14 @@ class Drupal_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sni /** * Determines if a comment line is part of an @code/@endcode example. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return boolean Returns true if the comment line is within a @code block, * false otherwise. */ - protected function isInCodeExample(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function isInCodeExample(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $prevComment = $stackPtr; @@ -358,13 +365,13 @@ class Drupal_Sniffs_Commenting_InlineCommentSniff implements PHP_CodeSniffer_Sni /** * Checks the indentation level of the comment contents. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - protected function processIndentation(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function processIndentation(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $comment = rtrim($tokens[$stackPtr]['content']); diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/PostStatementCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/PostStatementCommentSniff.php index ae38ded61e5b9f33626e287e280d1572a23b8d23..57b2091d746215cc5ca140e2264c775248fc7789 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/PostStatementCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/PostStatementCommentSniff.php @@ -1,21 +1,27 @@ <?php /** - * Drupal_Sniffs_Commenting_PostStatementCommentSniff. + * \Drupal\Sniffs\Commenting\PostStatementCommentSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** - * Largely copied from Squiz_Sniffs_Commenting_PostStatementCommentSniff but we want - * the fixer to move the comment to the previous line. + * Largely copied from + * \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\PostStatementCommentSniff + * but we want the fixer to move the comment to the previous line. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Commenting_PostStatementCommentSniff implements PHP_CodeSniffer_Sniff +class PostStatementCommentSniff implements Sniff { /** @@ -41,13 +47,13 @@ class Drupal_Sniffs_Commenting_PostStatementCommentSniff implements PHP_CodeSnif /** * Processes this sniff, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php index db3feeb6de3b08efcd68404b99005de6467344ba..9649f5b22653e6a532d2f89275d20d1f69d88e61 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php @@ -7,29 +7,37 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Commenting; + +use Drupal\Sniffs\Commenting\FunctionCommentSniff; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\AbstractVariableSniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Parses and verifies class property doc comments. * - * Laregely copied from Squiz_Sniffs_Commenting_VariableCommentSniff. + * Laregely copied from + * \PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\VariableCommentSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Commenting_VariableCommentSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff +class VariableCommentSniff extends AbstractVariableSniff { /** * Called to process class member vars. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function processMemberVar(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $commentToken = array( @@ -120,7 +128,7 @@ class Drupal_Sniffs_Commenting_VariableCommentSniff extends PHP_CodeSniffer_Stan // There may be multiple types separated by pipes. $suggestedTypes = array(); foreach (explode('|', $varType) as $type) { - $suggestedTypes[] = Drupal_Sniffs_Commenting_FunctionCommentSniff::suggestType($type); + $suggestedTypes[] = FunctionCommentSniff::suggestType($type); } $suggestedType = implode('|', $suggestedTypes); @@ -157,13 +165,13 @@ class Drupal_Sniffs_Commenting_VariableCommentSniff extends PHP_CodeSniffer_Stan * * Not required for this sniff. * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this token was found. - * @param int $stackPtr The position where the double quoted - * string was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this token was found. + * @param int $stackPtr The position where the double quoted + * string was found. * * @return void */ - protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function processVariable(File $phpcsFile, $stackPtr) { }//end processVariable() @@ -174,13 +182,13 @@ class Drupal_Sniffs_Commenting_VariableCommentSniff extends PHP_CodeSniffer_Stan * * Not required for this sniff. * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this token was found. - * @param int $stackPtr The position where the double quoted - * string was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this token was found. + * @param int $stackPtr The position where the double quoted + * string was found. * * @return void */ - protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function processVariableInString(File $phpcsFile, $stackPtr) { }//end processVariableInString() diff --git a/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php b/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php index 43f35ebddb169579601f5b580a9fae6f6e3a69c3..ab74cdbeb2e620e2c55443ee88412124a0704631 100644 --- a/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -7,17 +7,24 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\ControlStructures; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Verifies that control statements conform to their coding standards. * - * Largely copied from Squiz_Sniffs_ControlStructures_ControlSignatureSniff and - * adapted for Drupal's else on new lines. + * Largely copied from + * \PHP_CodeSniffer\Standards\Squiz\Sniffs\ControlStructures\ControlSignatureSniff + * and adapted for Drupal's else on new lines. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_ControlStructures_ControlSignatureSniff implements PHP_CodeSniffer_Sniff +class ControlSignatureSniff implements Sniff { /** @@ -57,13 +64,13 @@ class Drupal_Sniffs_ControlStructures_ControlSignatureSniff implements PHP_CodeS /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -155,7 +162,7 @@ class Drupal_Sniffs_ControlStructures_ControlSignatureSniff implements PHP_CodeS // Skip all empty tokens on the same line as the opener. if ($tokens[$next]['line'] === $tokens[$opener]['line'] - && (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$code]) === true + && (isset(Tokens::$emptyTokens[$code]) === true || $code === T_CLOSE_TAG) ) { continue; @@ -248,7 +255,7 @@ class Drupal_Sniffs_ControlStructures_ControlSignatureSniff implements PHP_CodeS || $tokens[$stackPtr]['code'] === T_ELSEIF || $tokens[$stackPtr]['code'] === T_CATCH ) { - $closer = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + $closer = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($closer === false || $tokens[$closer]['code'] !== T_CLOSE_CURLY_BRACKET) { return; } diff --git a/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php b/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php index 734453d355e990fe67bb13888b2a472e499b31d2..aabc01676bd9f0f00eb889e1458ec16f0777a479 100644 --- a/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php +++ b/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php @@ -7,6 +7,11 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\ControlStructures; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that "elseif" is used instead of "else if". * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_ControlStructures_ElseIfSniff implements PHP_CodeSniffer_Sniff +class ElseIfSniff implements Sniff { @@ -33,13 +38,13 @@ class Drupal_Sniffs_ControlStructures_ElseIfSniff implements PHP_CodeSniffer_Sni /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -54,7 +59,7 @@ class Drupal_Sniffs_ControlStructures_ElseIfSniff implements PHP_CodeSniffer_Sni ); if ($tokens[$nextNonWhiteSpace]['code'] === T_IF) { - $fix = $phpcsFile->addFixableError('Use "elseif" in place of "else if"', $nextNonWhiteSpace); + $fix = $phpcsFile->addFixableError('Use "elseif" in place of "else if"', $nextNonWhiteSpace, 'ElseIfDeclaration'); if ($fix === true) { $phpcsFile->fixer->beginChangeset(); $phpcsFile->fixer->replaceToken($stackPtr, 'elseif'); diff --git a/coder_sniffer/Drupal/Sniffs/ControlStructures/InlineControlStructureSniff.php b/coder_sniffer/Drupal/Sniffs/ControlStructures/InlineControlStructureSniff.php index c2dd39a14a305abf4c19e86b243fceb9619481d1..ef1fb70a1d4bc757825c7d6174e2d2e7c4413332 100644 --- a/coder_sniffer/Drupal/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/coder_sniffer/Drupal/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -1,14 +1,19 @@ <?php /** - * Drupal_Sniffs_ControlStructures_InlineControlStructureSniff. + * \Drupal\Sniffs\ControlStructures\InlineControlStructureSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\ControlStructures; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures\InlineControlStructureSniff as GenericInlineControlStructureSniff; + /** - * Drupal_Sniffs_ControlStructures_InlineControlStructureSniff. + * \Drupal\Sniffs\ControlStructures\InlineControlStructureSniff. * * Verifies that inline control statements are not present. This Sniff overides * the generic sniff because Drupal template files may use the alternative @@ -19,21 +24,20 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_ControlStructures_InlineControlStructureSniff -extends Generic_Sniffs_ControlStructures_InlineControlStructureSniff +class InlineControlStructureSniff extends GenericInlineControlStructureSniff { /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in + * the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php b/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php index 4f7d7b8864b850846401416b84d748677f1077ea..d829cda3e425835a7e8bd5d7e0fd577e8335b865 100644 --- a/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Files_EndFileNewlineSniff. + * \Drupal\Sniffs\Files\EndFileNewlineSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Files; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Ensures the file ends with a newline character. * @@ -17,7 +22,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Files_EndFileNewlineSniff implements PHP_CodeSniffer_Sniff +class EndFileNewlineSniff implements Sniff { @@ -51,13 +56,13 @@ class Drupal_Sniffs_Files_EndFileNewlineSniff implements PHP_CodeSniffer_Sniff /** * Processes this sniff, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in + * the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { // Skip to the end of the file. $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/Files/FileEncodingSniff.php b/coder_sniffer/Drupal/Sniffs/Files/FileEncodingSniff.php index a071f1c67a4d15f3afa9d693607b2e9525742d55..26a08da1a905d53342f69ba0535982b38dcc1680 100644 --- a/coder_sniffer/Drupal/Sniffs/Files/FileEncodingSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Files/FileEncodingSniff.php @@ -1,6 +1,6 @@ <?php /** - * Drupal_Sniffs_Files_FileEncodingSniff. + * \Drupal\Sniffs\Files\FileEncodingSniff. * * @category PHP * @package PHP_CodeSniffer @@ -10,8 +10,13 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Files; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** - * Drupal_Sniffs_Files_FileEncodingSniff. + * \Drupal\Sniffs\Files\FileEncodingSniff. * * Validates the encoding of a file against a white list of allowed encodings. * @@ -23,7 +28,7 @@ * @version Release: @package_version@ * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Files_FileEncodingSniff implements PHP_CodeSniffer_Sniff +class FileEncodingSniff implements Sniff { /** @@ -54,13 +59,13 @@ class Drupal_Sniffs_Files_FileEncodingSniff implements PHP_CodeSniffer_Sniff /** * Processes this sniff, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in + * the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { // Not all PHP installs have the multi byte extension - nothing we can do. if (function_exists('mb_check_encoding') === false) { diff --git a/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php b/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php index d77987c1a59d2b6ca67daf96da0d0663ec7080e9..90abba08a65bb24224bf727dd21677b763986d72 100644 --- a/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_Files_LineLengthSniff. + * \Drupal\Sniffs\Files\LineLengthSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Files; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff as GenericLineLengthSniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks comment lines in the file, and throws warnings if they are over 80 * characters in length. @@ -15,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Files_LineLengthSniff extends Generic_Sniffs_Files_LineLengthSniff +class LineLengthSniff extends GenericLineLengthSniff { /** @@ -39,15 +45,15 @@ class Drupal_Sniffs_Files_LineLengthSniff extends Generic_Sniffs_Files_LineLengt /** * Checks if a line is too long. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param array $tokens The token stack. - * @param int $stackPtr The first token on the next line. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param array $tokens The token stack. + * @param int $stackPtr The first token on the next line. * * @return void */ - protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr) + protected function checkLineLength($phpcsFile, $tokens, $stackPtr) { - if (isset(PHP_CodeSniffer_Tokens::$commentTokens[$tokens[($stackPtr - 1)]['code']]) === true) { + if (isset(Tokens::$commentTokens[$tokens[($stackPtr - 1)]['code']]) === true) { $doc_comment_tag = $phpcsFile->findFirstOnLine(T_DOC_COMMENT_TAG, ($stackPtr - 1)); if ($doc_comment_tag !== false) { // Allow doc comment tags such as long @param tags to exceed the 80 @@ -105,12 +111,12 @@ class Drupal_Sniffs_Files_LineLengthSniff extends Generic_Sniffs_Files_LineLengt /** * Returns the length of a defined line. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $currentLine The current line. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $currentLine The current line. * * @return int */ - public function getLineLength(PHP_CodeSniffer_File $phpcsFile, $currentLine) + public function getLineLength(File $phpcsFile, $currentLine) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php b/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php index 4ba76dd3c3e49f2602602cb20c1d35c94a03dceb..803a9e011ed0fb4e0c3247da5cb745157701e8ba 100644 --- a/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php @@ -1,14 +1,19 @@ <?php /** - * Drupal_Sniffs_Files_TxtFileLineLengthSniff. + * \Drupal\Sniffs\Files\TxtFileLineLengthSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Files; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** - * Drupal_Sniffs_Files_TxtFileLineLengthSniff. + * \Drupal\Sniffs\Files\TxtFileLineLengthSniff. * * Checks all lines in a *.txt or *.md file and throws warnings if they are over 80 * characters in length. @@ -17,7 +22,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Files_TxtFileLineLengthSniff implements PHP_CodeSniffer_Sniff +class TxtFileLineLengthSniff implements Sniff { @@ -36,13 +41,13 @@ class Drupal_Sniffs_Files_TxtFileLineLengthSniff implements PHP_CodeSniffer_Snif /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $fileExtension = strtolower(substr($phpcsFile->getFilename(), -3)); if ($fileExtension === 'txt' || $fileExtension === '.md') { @@ -51,10 +56,10 @@ class Drupal_Sniffs_Files_TxtFileLineLengthSniff implements PHP_CodeSniffer_Snif $content = rtrim($tokens[$stackPtr]['content']); $lineLength = mb_strlen($content, 'UTF-8'); // Lines without spaces are allowed to be longer (for example long URLs). - // Markdown is allowed to be longer for lines - // - without spaces. - // - starting with #. - // - containing URLs (https://). + // Markdown allowed to be longer for lines + // - without spaces + // - starting with # + // - containing URLs (https://) // - starting with | (tables). if ($lineLength > 80 && preg_match('/^([^ ]+$|#|.*https?:\/\/|\|)/', $content) === 0) { $data = array( diff --git a/coder_sniffer/Drupal/Sniffs/Formatting/MultiLineAssignmentSniff.php b/coder_sniffer/Drupal/Sniffs/Formatting/MultiLineAssignmentSniff.php index c7a52064f1e7b5d3ce8f94c83f2cd235d586e6b5..4b5c1c9154c601bfa2394e09e6c7b1ac1329ff2b 100644 --- a/coder_sniffer/Drupal/Sniffs/Formatting/MultiLineAssignmentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Formatting/MultiLineAssignmentSniff.php @@ -1,17 +1,19 @@ <?php /** - * PEAR_Sniffs_Functions_FunctionDeclarationSniff. + * \Drupal\Sniffs\Formatting\MultiLineAssignmentSniff. * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood <gsherwood@squiz.net> - * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer + * @category PHP + * @package PHP_CodeSniffer + * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Formatting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** - * Drupal_Sniffs_Formatting_MultiLineAssignmentSniff. + * \Drupal\Sniffs\Formatting\MultiLineAssignmentSniff. * * If an assignment goes over two lines, ensure the equal sign is indented. * @@ -23,7 +25,7 @@ * @version Release: 1.2.0RC3 * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Formatting_MultiLineAssignmentSniff implements PHP_CodeSniffer_Sniff +class MultiLineAssignmentSniff implements Sniff { @@ -42,13 +44,13 @@ class Drupal_Sniffs_Formatting_MultiLineAssignmentSniff implements PHP_CodeSniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -91,7 +93,7 @@ class Drupal_Sniffs_Formatting_MultiLineAssignmentSniff implements PHP_CodeSniff $foundIndent = strlen($tokens[$prev]['content']); if ($foundIndent !== $expectedIndent) { $error = "Multi-line assignment not indented correctly; expected $expectedIndent spaces but found $foundIndent"; - $phpcsFile->addError($error, $stackPtr); + $phpcsFile->addError($error, $stackPtr, 'MultiLineAssignmentIndent'); } }//end process() diff --git a/coder_sniffer/Drupal/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/coder_sniffer/Drupal/Sniffs/Formatting/MultipleStatementAlignmentSniff.php index bc029f27337dd08ecb810da030ec99dd843cca21..38071a461034605294b007f13446b8134284c267 100644 --- a/coder_sniffer/Drupal/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Formatting/MultipleStatementAlignmentSniff.php @@ -1,22 +1,28 @@ <?php /** - * Drupal_Sniffs_Formatting_MultipleStatementAlignmentSniff. + * \Drupal\Sniffs\Formatting\MultipleStatementAlignmentSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Formatting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\MultipleStatementAlignmentSniff as GenericMultipleStatementAlignmentSniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks alignment of multiple assignments.Largely copied from - * Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff but also allows multiple - * single space assignments. + * \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\MultipleStatementAlignmentSniff + * but also allows multiple single space assignments. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Formatting_MultipleStatementAlignmentSniff extends Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff +class MultipleStatementAlignmentSniff extends GenericMultipleStatementAlignmentSniff { @@ -31,13 +37,13 @@ class Drupal_Sniffs_Formatting_MultipleStatementAlignmentSniff extends Generic_S /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return int */ - public function checkAlignment(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function checkAlignment($phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -49,13 +55,13 @@ class Drupal_Sniffs_Formatting_MultipleStatementAlignmentSniff extends Generic_S $lastCode = $stackPtr; $lastSemi = null; - $find = PHP_CodeSniffer_Tokens::$assignmentTokens; + $find = Tokens::$assignmentTokens; unset($find[T_DOUBLE_ARROW]); for ($assign = $stackPtr; $assign < $phpcsFile->numTokens; $assign++) { if (isset($find[$tokens[$assign]['code']]) === false) { // A blank line indicates that the assignment block has ended. - if (isset(PHP_CodeSniffer_tokens::$emptyTokens[$tokens[$assign]['code']]) === false) { + if (isset(Tokens::$emptyTokens[$tokens[$assign]['code']]) === false) { if (($tokens[$assign]['line'] - $tokens[$lastCode]['line']) > 1) { break; } @@ -101,7 +107,7 @@ class Drupal_Sniffs_Formatting_MultipleStatementAlignmentSniff extends Generic_S }//end if $var = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($assign - 1), null, true diff --git a/coder_sniffer/Drupal/Sniffs/Formatting/SpaceInlineIfSniff.php b/coder_sniffer/Drupal/Sniffs/Formatting/SpaceInlineIfSniff.php index 138f5b1991f4f4d05b8db25dce912d13071ad798..8634c59574b9cae2aec987539ab587e5808b0e05 100644 --- a/coder_sniffer/Drupal/Sniffs/Formatting/SpaceInlineIfSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Formatting/SpaceInlineIfSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Formatting_SpaceInlineIfSniff. + * \Drupal\Sniffs\Formatting\SpaceInlineIfSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Formatting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that there is no space between "?" and ":" inline if/else statements. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Formatting_SpaceInlineIfSniff implements PHP_CodeSniffer_Sniff +class SpaceInlineIfSniff implements Sniff { @@ -33,13 +38,13 @@ class Drupal_Sniffs_Formatting_SpaceInlineIfSniff implements PHP_CodeSniffer_Sni /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in + * the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/Formatting/SpaceUnaryOperatorSniff.php b/coder_sniffer/Drupal/Sniffs/Formatting/SpaceUnaryOperatorSniff.php index 91bca8cad052af0120fafdddec84cd726e2b0a68..6fb7e18a0f3b956cb36ef2abe8d7e9eea80c3d17 100644 --- a/coder_sniffer/Drupal/Sniffs/Formatting/SpaceUnaryOperatorSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Formatting/SpaceUnaryOperatorSniff.php @@ -1,14 +1,20 @@ <?php /** - * Drupal_Sniffs_Formatting_SpaceUnaryOperatorSniff. + * \Drupal\Sniffs\Formatting\SpaceUnaryOperatorSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Formatting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** - * Drupal_Sniffs_Formatting_SpaceUnaryOperatorSniff. + * \PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceUnaryOperatorSniff. * * Ensures there are no spaces on increment / decrement statements or on +/- sign * operators or "!" boolean negators. @@ -17,7 +23,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Formatting_SpaceUnaryOperatorSniff implements PHP_CodeSniffer_Sniff +class SpaceUnaryOperatorSniff implements Sniff { @@ -42,19 +48,19 @@ class Drupal_Sniffs_Formatting_SpaceUnaryOperatorSniff implements PHP_CodeSniffe /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in + * the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); // Check decrement / increment. if ($tokens[$stackPtr]['code'] === T_DEC || $tokens[$stackPtr]['code'] === T_INC) { - $previous = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + $previous = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); $modifyLeft = in_array( $tokens[$previous]['code'], array( diff --git a/coder_sniffer/Drupal/Sniffs/Functions/DiscouragedFunctionsSniff.php b/coder_sniffer/Drupal/Sniffs/Functions/DiscouragedFunctionsSniff.php index e82c67d18c7b445d2017a32d8d279bd87445f952..d23f809e682c96afa108634870d8ebe57e61fdba 100644 --- a/coder_sniffer/Drupal/Sniffs/Functions/DiscouragedFunctionsSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Functions/DiscouragedFunctionsSniff.php @@ -1,12 +1,16 @@ <?php /** - * Drupal_Sniffs_Functions_DiscouragedFunctionsSniff. + * \Drupal\Sniffs\Functions\DiscouragedFunctionsSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Functions; + +use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff; + /** * Discourage the use of debug functions. * @@ -14,7 +18,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Functions_DiscouragedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff +class DiscouragedFunctionsSniff extends ForbiddenFunctionsSniff { /** diff --git a/coder_sniffer/Drupal/Sniffs/Functions/FunctionDeclarationSniff.php b/coder_sniffer/Drupal/Sniffs/Functions/FunctionDeclarationSniff.php index b539a647f9709db4a2cc29600531340f1916f065..c4d26a0d372e5b100d02a57ea81443b2f8287995 100644 --- a/coder_sniffer/Drupal/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Functions/FunctionDeclarationSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Functions_FunctionDeclarationSniff. + * \Drupal\Sniffs\Functions\FunctionDeclarationSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Functions; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Ensure that there is only one space after the function keyword and no space * before the opening parenthesis. @@ -18,7 +23,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Functions_FunctionDeclarationSniff implements PHP_CodeSniffer_Sniff +class FunctionDeclarationSniff implements Sniff { @@ -37,13 +42,13 @@ class Drupal_Sniffs_Functions_FunctionDeclarationSniff implements PHP_CodeSniffe /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/InfoFiles/AutoAddedKeysSniff.php b/coder_sniffer/Drupal/Sniffs/InfoFiles/AutoAddedKeysSniff.php index ee72d42a715f2ceca68f91a96122ff2c2a43afd2..98e474e4517dd4587c6728bbe5bfba2e108e61f7 100644 --- a/coder_sniffer/Drupal/Sniffs/InfoFiles/AutoAddedKeysSniff.php +++ b/coder_sniffer/Drupal/Sniffs/InfoFiles/AutoAddedKeysSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_InfoFiles_RequiredSniff. + * \Drupal\Sniffs\InfoFiles\RequiredSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\InfoFiles; + +use Drupal\Sniffs\InfoFiles\ClassFilesSniff; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * "version", "project" and "timestamp" are added automatically by drupal.org * packaging scripts. @@ -15,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_InfoFiles_AutoAddedKeysSniff implements PHP_CodeSniffer_Sniff +class AutoAddedKeysSniff implements Sniff { @@ -34,19 +40,19 @@ class Drupal_Sniffs_InfoFiles_AutoAddedKeysSniff implements PHP_CodeSniffer_Snif /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. * * @return int */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { // Only run this sniff once per info file. if (preg_match('/\.info$/', $phpcsFile->getFilename()) === 1) { // Drupal 7 style info file. $contents = file_get_contents($phpcsFile->getFilename()); - $info = Drupal_Sniffs_InfoFiles_ClassFilesSniff::drupalParseInfoFormat($contents); + $info = ClassFilesSniff::drupalParseInfoFormat($contents); } else if (preg_match('/\.info\.yml$/', $phpcsFile->getFilename()) === 1) { // Drupal 8 style info.yml file. $contents = file_get_contents($phpcsFile->getFilename()); diff --git a/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php b/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php index 733e13fb1f3c4c03019261c13a590b952c2a0f65..681e19893e79e10568976a69e3038d998379b166 100644 --- a/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php +++ b/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_InfoFiles_ClassFilesSniff. + * \Drupal\Sniffs\InfoFiles\ClassFilesSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\InfoFiles; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks files[] entries in info files. Only files containing classes/interfaces * should be listed. @@ -15,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_InfoFiles_ClassFilesSniff implements PHP_CodeSniffer_Sniff +class ClassFilesSniff implements Sniff { @@ -34,13 +39,13 @@ class Drupal_Sniffs_InfoFiles_ClassFilesSniff implements PHP_CodeSniffer_Sniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. * * @return int */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { // Only run this sniff once per info file. $fileExtension = strtolower(substr($phpcsFile->getFilename(), -4)); @@ -87,14 +92,14 @@ class Drupal_Sniffs_InfoFiles_ClassFilesSniff implements PHP_CodeSniffer_Sniff /** * Helper function that returns the position of the key in the info file. * - * @param string $key Key name to search for. - * @param string $value Corresponding value to search for. - * @param PHP_CodeSniffer_File $infoFile Info file to search in. + * @param string $key Key name to search for. + * @param string $value Corresponding value to search for. + * @param \PHP_CodeSniffer\Files\File $infoFile Info file to search in. * * @return int|false Returns the stack position if the file name is found, false * otherwise. */ - public static function getPtr($key, $value, PHP_CodeSniffer_File $infoFile) + 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) { diff --git a/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php b/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php index 974c408c574b4abe908efa797d7d3ae7312c8765..a6d52858bfdf7211283ef9c7c6a93d921b6a6bdc 100644 --- a/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php +++ b/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_InfoFiles_DuplicateEntrySniff. + * \Drupal\Sniffs\InfoFiles\DuplicateEntrySniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\InfoFiles; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Make sure that entries in info files are specified only once. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_InfoFiles_DuplicateEntrySniff implements PHP_CodeSniffer_Sniff +class DuplicateEntrySniff implements Sniff { @@ -33,13 +38,13 @@ class Drupal_Sniffs_InfoFiles_DuplicateEntrySniff implements PHP_CodeSniffer_Sni /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. * * @return int */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { // Only run this sniff once per info file. $fileExtension = strtolower(substr($phpcsFile->getFilename(), -4)); diff --git a/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php b/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php index 941c197fd64697a510320920915375fa44803ebc..67a03c56767186b698042c3d738ac3d8ef70f86c 100644 --- a/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php +++ b/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_InfoFiles_RequiredSniff. + * \Drupal\Sniffs\InfoFiles\RequiredSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\InfoFiles; + +use Drupal\Sniffs\InfoFiles\ClassFilesSniff; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * "name", "description" and "core are required fields in Drupal info files. Also * checks the "php" minimum requirement for Drupal 7. @@ -15,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_InfoFiles_RequiredSniff implements PHP_CodeSniffer_Sniff +class RequiredSniff implements Sniff { @@ -34,13 +40,13 @@ class Drupal_Sniffs_InfoFiles_RequiredSniff implements PHP_CodeSniffer_Sniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. * * @return int */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { // Only run this sniff once per info file. $fileExtension = strtolower(substr($phpcsFile->getFilename(), -4)); @@ -49,7 +55,7 @@ class Drupal_Sniffs_InfoFiles_RequiredSniff implements PHP_CodeSniffer_Sniff } $contents = file_get_contents($phpcsFile->getFilename()); - $info = Drupal_Sniffs_InfoFiles_ClassFilesSniff::drupalParseInfoFormat($contents); + $info = ClassFilesSniff::drupalParseInfoFormat($contents); if (isset($info['name']) === false) { $error = '"name" property is missing in the info file'; $phpcsFile->addError($error, $stackPtr, 'Name'); @@ -67,7 +73,7 @@ class Drupal_Sniffs_InfoFiles_RequiredSniff implements PHP_CodeSniffer_Sniff && $info['php'] <= '5.2' ) { $error = 'Drupal 7 core already requires PHP 5.2'; - $ptr = Drupal_Sniffs_InfoFiles_ClassFilesSniff::getPtr('php', $info['php'], $phpcsFile); + $ptr = ClassFilesSniff::getPtr('php', $info['php'], $phpcsFile); $phpcsFile->addError($error, $ptr, 'D7PHPVersion'); } diff --git a/coder_sniffer/Drupal/Sniffs/Methods/MethodDeclarationSniff.php b/coder_sniffer/Drupal/Sniffs/Methods/MethodDeclarationSniff.php index 63661a0b89f6c7ecf49e644a1fb33ed3397c25c8..d36b32db17f1a7bb226c6b03b8897474f7d85646 100644 --- a/coder_sniffer/Drupal/Sniffs/Methods/MethodDeclarationSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Methods/MethodDeclarationSniff.php @@ -1,22 +1,29 @@ <?php /** - * Drupal_Sniffs_Methods_MethodDeclarationSniff. + * \Drupal\Sniffs\Methods\MethodDeclarationSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Methods; + +use PHP_CodeSniffer\Sniffs\AbstractScopeSniff; +use PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff as PSR2MethodDeclarationSniff; + /** * Checks that the method declaration is correct. * - * Extending PSR2_Sniffs_Methods_MethodDeclarationSniff to also support traits. + * Extending + * \PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff + * to also support traits. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Methods_MethodDeclarationSniff extends PSR2_Sniffs_Methods_MethodDeclarationSniff +class MethodDeclarationSniff extends PSR2MethodDeclarationSniff { @@ -25,7 +32,7 @@ class Drupal_Sniffs_Methods_MethodDeclarationSniff extends PSR2_Sniffs_Methods_M */ public function __construct() { - PHP_CodeSniffer_Standards_AbstractScopeSniff::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION)); + AbstractScopeSniff::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION)); }//end __construct() diff --git a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php index 0d6a90a1ec6b712799d951689d09f22acf876735..5f3ca71b8d0c768e64a2cf6fd4aaade77c85cc61 100644 --- a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php +++ b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php @@ -1,6 +1,6 @@ <?php /** - * Drupal_Sniffs_NamingConventions_ValidClassNameSniff. + * \Drupal\Sniffs\NamingConventions\ValidClassNameSniff. * * @category PHP * @package PHP_CodeSniffer @@ -11,8 +11,13 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\NamingConventions; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** - * Drupal_Sniffs_NamingConventions_ValidClassNameSniff. + * \Drupal\Sniffs\NamingConventions\ValidClassNameSniff. * * Ensures class and interface names start with a capital letter * and do not use _ separators. @@ -26,7 +31,7 @@ * @version Release: 1.2.0RC3 * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_NamingConventions_ValidClassNameSniff implements PHP_CodeSniffer_Sniff +class ValidClassNameSniff implements Sniff { @@ -48,13 +53,13 @@ class Drupal_Sniffs_NamingConventions_ValidClassNameSniff implements PHP_CodeSni /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The current file being processed. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidFunctionNameSniff.php index b0b0f4af5112d532bfa1938c7649d21fbe705dc3..5f6b1ab70071a3f1fbd5759d719807d194c7a4fb 100644 --- a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -1,38 +1,45 @@ <?php /** - * Drupal_Sniffs_NamingConventions_ValidFunctionNameSniff. + * \Drupal\Sniffs\NamingConventions\ValidFunctionNameSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\NamingConventions; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff; +use PHP_CodeSniffer\Util\Common; + /** - * Drupal_Sniffs_NamingConventions_ValidFunctionNameSniff. + * \Drupal\Sniffs\NamingConventions\ValidFunctionNameSniff. * - * Extends Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff to also check - * global function names outside the scope of classes and to not allow methods - * beginning with an underscore. + * Extends + * \PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff + * to also check global function names outside the scope of classes and to not + * allow methods beginning with an underscore. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_NamingConventions_ValidFunctionNameSniff extends Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff +class ValidFunctionNameSniff extends CamelCapsFunctionNameSniff { /** * Processes the tokens within the scope. * - * @param PHP_CodeSniffer_File $phpcsFile The file being processed. - * @param int $stackPtr The position where this token was - * found. - * @param int $currScope The position of the current scope. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being processed. + * @param int $stackPtr The position where this token was + * found. + * @param int $currScope The position of the current scope. * * @return void */ - protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) + protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) { $methodName = $phpcsFile->getDeclarationName($stackPtr); if ($methodName === null) { @@ -57,7 +64,7 @@ class Drupal_Sniffs_NamingConventions_ValidFunctionNameSniff extends Generic_Sni } $methodProps = $phpcsFile->getMethodProperties($stackPtr); - if (PHP_CodeSniffer::isCamelCaps($methodName, false, true, $this->strict) === false) { + if (Common::isCamelCaps($methodName, false, true, $this->strict) === false) { if ($methodProps['scope_specified'] === true) { $error = '%s method name "%s" is not in lowerCamel format'; $data = array( @@ -82,13 +89,13 @@ class Drupal_Sniffs_NamingConventions_ValidFunctionNameSniff extends Generic_Sni /** * Processes the tokens outside the scope. * - * @param PHP_CodeSniffer_File $phpcsFile The file being processed. - * @param int $stackPtr The position where this token was - * found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being processed. + * @param int $stackPtr The position where this token was + * found. * * @return void */ - protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) { $functionName = $phpcsFile->getDeclarationName($stackPtr); if ($functionName === null) { diff --git a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidGlobalSniff.php b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidGlobalSniff.php index 1422c4857ee4445ff8513507eb6bbd010af4d29a..91666759786f8d05e00083ed552a081bb8fafba1 100644 --- a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidGlobalSniff.php +++ b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidGlobalSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_NamingConventions_ValidGlobalSniff. + * \Drupal\Sniffs\NamingConventions\ValidGlobalSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\NamingConventions; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Ensures that global variables start with an underscore. * @@ -14,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_NamingConventions_ValidGlobalSniff implements PHP_CodeSniffer_Sniff +class ValidGlobalSniff implements Sniff { public $coreGlobals = array( @@ -83,19 +89,19 @@ class Drupal_Sniffs_NamingConventions_ValidGlobalSniff implements PHP_CodeSniffe /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The current file being processed. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $varToken = $stackPtr; // Find variable names until we hit a semicolon. - $ignore = PHP_CodeSniffer_Tokens::$emptyTokens; + $ignore = Tokens::$emptyTokens; $ignore[] = T_SEMICOLON; while (($varToken = $phpcsFile->findNext($ignore, ($varToken + 1), null, true, null, true)) !== false) { if ($tokens[$varToken]['code'] === T_VARIABLE diff --git a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php index d092ea84fc1634a17f7ede26d74d8d0e64a1fd92..4f8cf0aad9c48196b1f95ad2838d97cf91ab09f9 100644 --- a/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -1,14 +1,19 @@ <?php /** - * Drupal_Sniffs_NamingConventions_ValidVariableNameSniff. + * \Drupal\Sniffs\NamingConventions\ValidVariableNameSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\NamingConventions; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\AbstractVariableSniff; + /** - * Drupal_Sniffs_NamingConventions_ValidVariableNameSniff. + * \Drupal\Sniffs\NamingConventions\ValidVariableNameSniff. * * Checks the naming of member variables. * @@ -16,22 +21,20 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_NamingConventions_ValidVariableNameSniff - - extends PHP_CodeSniffer_Standards_AbstractVariableSniff +class ValidVariableNameSniff extends AbstractVariableSniff { /** * Processes class member variables. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function processMemberVar(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -71,12 +74,12 @@ class Drupal_Sniffs_NamingConventions_ValidVariableNameSniff /** * Processes normal variables. * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. * * @return void */ - protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function processVariable(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -115,12 +118,12 @@ class Drupal_Sniffs_NamingConventions_ValidVariableNameSniff /** * Processes variables in double quoted strings. * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. * * @return void */ - protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function processVariableInString(File $phpcsFile, $stackPtr) { // We don't care about variables in strings. return; diff --git a/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php b/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php index 6831beb5b0ac9b16a7ec778edd3fe9843a699ea0..bd8532e812a09910c9a73f15745a1d7a98a2e5c5 100644 --- a/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php @@ -7,22 +7,30 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Scope; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\AbstractScopeSniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Verifies that class/interface/trait methods have scope modifiers. * - * Laregely copied from Squiz_Sniffs_Scope_MethodScopeSniff to work on traits - * and have a fixer. + * Laregely copied from + * \PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MethodScopeSniff to work on + * traits and have a fixer. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Scope_MethodScopeSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +class MethodScopeSniff extends AbstractScopeSniff { /** - * Constructs a Squiz_Sniffs_Scope_MethodScopeSniff. + * Constructs a + * \PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MethodScopeSniff. */ public function __construct() { @@ -34,13 +42,13 @@ class Drupal_Sniffs_Scope_MethodScopeSniff extends PHP_CodeSniffer_Standards_Abs /** * Processes the function tokens within the class. * - * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found. - * @param int $stackPtr The position where the token was found. - * @param int $currScope The current scope opener token. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found. + * @param int $stackPtr The position where the token was found. + * @param int $currScope The current scope opener token. * * @return void */ - protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) + protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) { $tokens = $phpcsFile->getTokens(); @@ -59,7 +67,7 @@ class Drupal_Sniffs_Scope_MethodScopeSniff extends PHP_CodeSniffer_Standards_Abs for ($i = ($stackPtr - 1); $i > 0; $i--) { if ($tokens[$i]['line'] < $tokens[$stackPtr]['line']) { break; - } else if (isset(PHP_CodeSniffer_Tokens::$scopeModifiers[$tokens[$i]['code']]) === true) { + } else if (isset(Tokens::$scopeModifiers[$tokens[$i]['code']]) === true) { $modifier = $i; break; } @@ -80,4 +88,20 @@ class Drupal_Sniffs_Scope_MethodScopeSniff extends PHP_CodeSniffer_Standards_Abs }//end processTokenWithinScope() + /** + * Processes a token that is found outside the scope that this test is + * listening to. + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found. + * @param int $stackPtr The position in the stack where this + * token was found. + * + * @return void + */ + 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 d9903f5fec1be3a4d877ede9dc5ca8e1ed9462f0..9fb999d01267ea2e52aaef371107d23ed62912bc 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/ConstantNameSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/ConstantNameSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Semantics_ConstantNameSniff + * \Drupal\Sniffs\Semantics\ConstantNameSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use Drupal\Sniffs\Semantics\FunctionCall; +use PHP_CodeSniffer\Files\File; + /** * Checks that constants introduced with define() in module or install files start * with the module's name. @@ -15,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Semantics_ConstantNameSniff extends Drupal_Sniffs_Semantics_FunctionCall +class ConstantNameSniff extends FunctionCall { @@ -34,18 +39,18 @@ class Drupal_Sniffs_Semantics_ConstantNameSniff extends Drupal_Sniffs_Semantics_ /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/EmptyInstallSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/EmptyInstallSniff.php index a042fbcc0c77693b080d2fbe276d04fde5c3c109..d747d7052e9dd143fcf875f93fd440a448708d59 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/EmptyInstallSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/EmptyInstallSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_Semantics_EmptyInstallSniff. + * \Drupal\Sniffs\Semantics\EmptyInstallSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use Drupal\Sniffs\Semantics\FunctionDefinition; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Util\Tokens; + /** * Throws an error if hook_install() or hook_uninstall() definitions are empty. * @@ -14,22 +20,22 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Semantics_EmptyInstallSniff extends Drupal_Sniffs_Semantics_FunctionDefinition +class EmptyInstallSniff extends FunctionDefinition { /** * Process this function definition. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function name in the stack. - * name in the stack. - * @param int $functionPtr The position of the function keyword in the stack. - * keyword in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function name in the stack. + * name in the stack. + * @param int $functionPtr The position of the function keyword in the stack. + * keyword in the stack. * * @return void */ - public function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr) + public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) { $fileExtension = strtolower(substr($phpcsFile->getFilename(), -7)); // Only check in *.install files. @@ -44,7 +50,7 @@ class Drupal_Sniffs_Semantics_EmptyInstallSniff extends Drupal_Sniffs_Semantics_ ) { // Check if there is a function body. $bodyPtr = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($tokens[$functionPtr]['scope_opener'] + 1), $tokens[$functionPtr]['scope_closer'], true diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionAliasSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionAliasSniff.php index 39a2a87a8017a04efbcf4b0f602439e7e8a583ca..ee7e12af38ad04ff43731dcaca608d68b1694047 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionAliasSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionAliasSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Semantics_FunctionAliasSniff + * \Drupal\Sniffs\Semantics\FunctionAliasSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use Drupal\Sniffs\Semantics\FunctionCall; +use PHP_CodeSniffer\Files\File; + /** * Checks that no PHP function name aliases are used. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Semantics_FunctionAliasSniff extends Drupal_Sniffs_Semantics_FunctionCall +class FunctionAliasSniff extends FunctionCall { /** @@ -191,18 +196,18 @@ class Drupal_Sniffs_Semantics_FunctionAliasSniff extends Drupal_Sniffs_Semantics /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php index 2570d02f9d7260f7093cdf90708224c031dfca40..daa4f234bfdc901c2a09f0cf419fa373ea72e778 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_Semantics_FunctionCall. + * \Drupal\Sniffs\Semantics\FunctionCall. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Helper class to sniff for specific function calls. * @@ -14,13 +20,13 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -abstract class Drupal_Sniffs_Semantics_FunctionCall implements PHP_CodeSniffer_Sniff +abstract class FunctionCall implements Sniff { /** * The currently processed file. * - * @var PHP_CodeSniffer_File + * @var \PHP_CodeSniffer\Files\File */ protected $phpcsFile; @@ -76,13 +82,13 @@ abstract class Drupal_Sniffs_Semantics_FunctionCall implements PHP_CodeSniffer_S /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $functionName = $tokens[$stackPtr]['content']; @@ -96,7 +102,7 @@ abstract class Drupal_Sniffs_Semantics_FunctionCall implements PHP_CodeSniffer_S } // Find the next non-empty token. - $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); + $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); $this->phpcsFile = $phpcsFile; $this->functionCall = $stackPtr; @@ -112,17 +118,17 @@ abstract class Drupal_Sniffs_Semantics_FunctionCall implements PHP_CodeSniffer_S /** * Checks if this is a function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return bool */ - protected function isFunctionCall(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function isFunctionCall(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); // Find the next non-empty token. - $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); + $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) { // Not a function call. @@ -135,7 +141,7 @@ abstract class Drupal_Sniffs_Semantics_FunctionCall implements PHP_CodeSniffer_S } // Find the previous non-empty token. - $search = PHP_CodeSniffer_Tokens::$emptyTokens; + $search = Tokens::$emptyTokens; $search[] = T_BITWISE_AND; $previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true); if ($tokens[$previous]['code'] === T_FUNCTION) { @@ -175,14 +181,14 @@ abstract class Drupal_Sniffs_Semantics_FunctionCall implements PHP_CodeSniffer_S $tokens = $this->phpcsFile->getTokens(); // Start token of the first argument. - $start = $this->phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($this->openBracket + 1), null, true); + $start = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($this->openBracket + 1), null, true); if ($start === $this->closeBracket) { // Function call has no arguments, so return false. return false; } // End token of the last argument. - $end = $this->phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($this->closeBracket - 1), null, true); + $end = $this->phpcsFile->findPrevious(Tokens::$emptyTokens, ($this->closeBracket - 1), null, true); $lastArgEnd = $end; $nextSeperator = $this->openBracket; $counter = 1; @@ -196,7 +202,7 @@ abstract class Drupal_Sniffs_Semantics_FunctionCall implements PHP_CodeSniffer_S } // Update the end token of the current argument. - $end = $this->phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextSeperator - 1), null, true); + $end = $this->phpcsFile->findPrevious(Tokens::$emptyTokens, ($nextSeperator - 1), null, true); // Save the calculated findings for the current argument. $this->arguments[$counter] = array( 'start' => $start, @@ -207,7 +213,7 @@ abstract class Drupal_Sniffs_Semantics_FunctionCall implements PHP_CodeSniffer_S } $counter++; - $start = $this->phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextSeperator + 1), null, true); + $start = $this->phpcsFile->findNext(Tokens::$emptyTokens, ($nextSeperator + 1), null, true); $end = $lastArgEnd; }//end while diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.php b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.php index 02ab30367d191dae71ff03430340e5af53ac3e9e..7d047acd49666866e5a6de56f94a3737440a6bfd 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_Semantics_FunctionDefinition. + * \Drupal\Sniffs\Semantics\FunctionDefinition. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Helper class to sniff for function definitions. * @@ -14,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -abstract class Drupal_Sniffs_Semantics_FunctionDefinition implements PHP_CodeSniffer_Sniff +abstract class FunctionDefinition implements Sniff { @@ -33,18 +39,18 @@ abstract class Drupal_Sniffs_Semantics_FunctionDefinition implements PHP_CodeSni /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); // Check if this is a function definition. $functionPtr = $phpcsFile->findPrevious( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($stackPtr - 1), null, true @@ -59,15 +65,15 @@ abstract class Drupal_Sniffs_Semantics_FunctionDefinition implements PHP_CodeSni /** * Process this function definition. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function name in the stack. - * name in the stack. - * @param int $functionPtr The position of the function keyword in the stack. - * keyword in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function name in the stack. + * name in the stack. + * @param int $functionPtr The position of the function keyword in the stack. + * keyword in the stack. * * @return void */ - public abstract function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr); + public abstract 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 e53858579ccde205732e7bf9f67ed819461d7865..cbf3f7fa8196838f60948dfa8d22e8fdf730720a 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_Semantics_FunctionTSniff + * \Drupal\Sniffs\Semantics\FunctionTSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use Drupal\Sniffs\Semantics\FunctionCall; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Util\Tokens; + /** * Check the usage of the t() function to not escape translateable strings with back * slashes. Also checks that the first argument does not use string concatenation. @@ -15,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Semantics_FunctionTSniff extends Drupal_Sniffs_Semantics_FunctionCall +class FunctionTSniff extends FunctionCall { /** @@ -45,18 +51,18 @@ class Drupal_Sniffs_Semantics_FunctionTSniff extends Drupal_Sniffs_Semantics_Fun /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket @@ -84,9 +90,9 @@ class Drupal_Sniffs_Semantics_FunctionTSniff extends Drupal_Sniffs_Semantics_Fun return; } - $concatAfter = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($closeBracket + 1), null, true, null, true); + $concatAfter = $phpcsFile->findNext(Tokens::$emptyTokens, ($closeBracket + 1), null, true, null, true); if ($concatAfter !== false && $tokens[$concatAfter]['code'] === T_STRING_CONCAT) { - $stringAfter = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($concatAfter + 1), null, true, null, true); + $stringAfter = $phpcsFile->findNext(Tokens::$emptyTokens, ($concatAfter + 1), null, true, null, true); if ($stringAfter !== false && $tokens[$stringAfter]['code'] === T_CONSTANT_ENCAPSED_STRING && $this->checkConcatString($tokens[$stringAfter]['content']) === false diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionWatchdogSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionWatchdogSniff.php index 7117bdbc91bfbc0f5219ff5655e511db27d10920..05b952c07f36b7b25903459842f4d476316a2cb3 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/FunctionWatchdogSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/FunctionWatchdogSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Semanitcs_FunctionWatchdogSniff. + * \Drupal\Sniffs\Semantics\FunctionWatchdogSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use Drupal\Sniffs\Semantics\FunctionCall; +use PHP_CodeSniffer\Files\File; + /** * Checks that the second argument to watchdog() is not enclosed with t(). * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Semantics_FunctionWatchdogSniff extends Drupal_Sniffs_Semantics_FunctionCall +class FunctionWatchdogSniff extends FunctionCall { @@ -33,18 +38,18 @@ class Drupal_Sniffs_Semantics_FunctionWatchdogSniff extends Drupal_Sniffs_Semant /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/InstallHooksSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/InstallHooksSniff.php index 96b5315fb198de189beab3d7e83070cb07af059e..41aaf3e828262d008ad8794d2329b189351660d1 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/InstallHooksSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/InstallHooksSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Semantics_InstallHooksSniff + * \Drupal\Sniffs\Semantics\InstallHooksSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use Drupal\Sniffs\Semantics\FunctionDefinition; +use PHP_CodeSniffer\Files\File; + /** * Checks that hook_disable(), hook_enable(), hook_install(), hook_uninstall(), * hook_requirements() and hook_schema() are not defined in the module file. @@ -15,22 +20,22 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Semantics_InstallHooksSniff extends Drupal_Sniffs_Semantics_FunctionDefinition +class InstallHooksSniff extends FunctionDefinition { /** * Process this function definition. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function name in the stack. - * name in the stack. - * @param int $functionPtr The position of the function keyword in the stack. - * keyword in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function name in the stack. + * name in the stack. + * @param int $functionPtr The position of the function keyword in the stack. + * keyword in the stack. * * @return void */ - public function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr) + public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) { $fileExtension = strtolower(substr($phpcsFile->getFilename(), -6)); // Only check in *.module files. diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/LStringTranslatableSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/LStringTranslatableSniff.php index 6b48994c67de669a095f14b43098026736e6e171..a8edcef9d323425746ea366d8d2268c6442e5c24 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/LStringTranslatableSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/LStringTranslatableSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Semanitcs_LStringTranslatableSniff. + * \Drupal\Sniffs\Semantics\LStringTranslatableSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use Drupal\Sniffs\Semantics\FunctionCall; +use PHP_CodeSniffer\Files\File; + /** * Checks that string literals passed to l() are translatable. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Semantics_LStringTranslatableSniff extends Drupal_Sniffs_Semantics_FunctionCall +class LStringTranslatableSniff extends FunctionCall { @@ -33,18 +38,18 @@ class Drupal_Sniffs_Semantics_LStringTranslatableSniff extends Drupal_Sniffs_Sem /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php index f976d7644f5231ba41381bb6ab1d99fb710c5cc3..67ba73c5e67de40f37555141a0c3e7ac997a960d 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Semantics_PregSecuritySniff. + * \Drupal\Sniffs\Semantics\PregSecuritySniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use Drupal\Sniffs\Semantics\FunctionCall; +use PHP_CodeSniffer\Files\File; + /** * Check the usage of the preg functions to ensure the insecure /e flag isn't * used: https://www.drupal.org/node/750148 @@ -15,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Semantics_PregSecuritySniff extends Drupal_Sniffs_Semantics_FunctionCall +class PregSecuritySniff extends FunctionCall { @@ -42,18 +47,18 @@ class Drupal_Sniffs_Semantics_PregSecuritySniff extends Drupal_Sniffs_Semantics_ /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/RemoteAddressSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/RemoteAddressSniff.php index b68aac6f116788922d16770d64a322e016e0fb4e..14020e29fd0f16d7d8453982bf657a5ebe8d1726 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/RemoteAddressSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/RemoteAddressSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Semantics_RemoteAddressSniff. + * \Drupal\Sniffs\Semantics\RemoteAddressSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Make sure that the function ip_address() is used instead of * $_SERVER['REMOTE_ADDR']. @@ -15,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Semantics_RemoteAddressSniff implements PHP_CodeSniffer_Sniff +class RemoteAddressSniff implements Sniff { @@ -34,13 +39,13 @@ class Drupal_Sniffs_Semantics_RemoteAddressSniff implements PHP_CodeSniffer_Snif /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \HP_CodeSniffer\Files\File $phpcsFile The current file being processed. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $string = $phpcsFile->getTokensAsString($stackPtr, 4); if ($string === '$_SERVER["REMOTE_ADDR"]' || $string === '$_SERVER[\'REMOTE_ADDR\']') { diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.php index bb25f3770d6441465eae93186feb2db25f345ea0..08cfc804bb938889986826228d18d8f9f075c862 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_Semanitcs_TInHookMenuSniff. + * \Drupal\Sniffs\Semantics\TInHookMenuSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use Drupal\Sniffs\Semantics\FunctionDefinition; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks that t() is not used in hook_menu(). * @@ -14,22 +20,22 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Semantics_TInHookMenuSniff extends Drupal_Sniffs_Semantics_FunctionDefinition +class TInHookMenuSniff extends FunctionDefinition { /** * Process this function definition. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function name in the stack. - * name in the stack. - * @param int $functionPtr The position of the function keyword in the stack. - * keyword in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function name in the stack. + * name in the stack. + * @param int $functionPtr The position of the function keyword in the stack. + * keyword in the stack. * * @return void */ - public function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr) + public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) { $fileExtension = strtolower(substr($phpcsFile->getFilename(), -6)); // Only check in *.module files. @@ -52,7 +58,7 @@ class Drupal_Sniffs_Semantics_TInHookMenuSniff extends Drupal_Sniffs_Semantics_F while ($string !== false) { if ($tokens[$string]['content'] === 't') { $opener = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($string + 1), null, true diff --git a/coder_sniffer/Drupal/Sniffs/Semantics/TInHookSchemaSniff.php b/coder_sniffer/Drupal/Sniffs/Semantics/TInHookSchemaSniff.php index e10ce0aac41fb6026f10123de87ae620d3e4b54a..490df8eca086da74b664e28c3e92ff5f8d089884 100644 --- a/coder_sniffer/Drupal/Sniffs/Semantics/TInHookSchemaSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Semantics/TInHookSchemaSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_Semanitcs_TInHookSchemaSniff. + * \Drupal\Sniffs\Semantics\TInHookSchemaSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Semantics; + +use Drupal\Sniffs\Semantics\FunctionDefinition; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks that t() is not used in hook_schema(). * @@ -14,22 +20,22 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Semantics_TInHookSchemaSniff extends Drupal_Sniffs_Semantics_FunctionDefinition +class TInHookSchemaSniff extends FunctionDefinition { /** * Process this function definition. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function name in the stack. - * name in the stack. - * @param int $functionPtr The position of the function keyword in the stack. - * keyword in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function name in the stack. + * name in the stack. + * @param int $functionPtr The position of the function keyword in the stack. + * keyword in the stack. * * @return void */ - public function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr) + public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) { $fileExtension = strtolower(substr($phpcsFile->getFilename(), -7)); // Only check in *.install files. @@ -52,7 +58,7 @@ class Drupal_Sniffs_Semantics_TInHookSchemaSniff extends Drupal_Sniffs_Semantics while ($string !== false) { if ($tokens[$string]['content'] === 't') { $opener = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($string + 1), null, true diff --git a/coder_sniffer/Drupal/Sniffs/Strings/UnnecessaryStringConcatSniff.php b/coder_sniffer/Drupal/Sniffs/Strings/UnnecessaryStringConcatSniff.php index 69d12a81f784f807a096789f8d02862617294f90..d96dfa462836247796363520f6e2ee240744b998 100644 --- a/coder_sniffer/Drupal/Sniffs/Strings/UnnecessaryStringConcatSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Strings/UnnecessaryStringConcatSniff.php @@ -1,44 +1,46 @@ <?php /** - * Generic_Sniffs_Strings_UnnecessaryStringConcatSniff. + * \Drupal\Sniffs\Strings\UnnecessaryStringConcatSniff. * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> - * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: UnnecessaryStringConcatSniff.php 304603 2010-10-22 03:07:04Z squiz $ + * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\Strings; + +use Drupal\Sniffs\Files\LineLengthSniff; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Standards\Generic\Sniffs\Strings\UnnecessaryStringConcatSniff as GenericUnnecessaryStringConcatSniff; +use PHP_CodeSniffer\Util\Tokens; + /** - * Generic_Sniffs_Strings_UnnecessaryStringConcatSniff. - * - * Checks that two strings are not concatenated together; suggests - * using one string instead. + * Checks that two strings are not concatenated together; suggests using one string instead. * * @category PHP * @package PHP_CodeSniffer * @author Greg Sherwood <gsherwood@squiz.net> - * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) - * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version Release: 1.3.1 + * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_Strings_UnnecessaryStringConcatSniff extends Generic_Sniffs_Strings_UnnecessaryStringConcatSniff +class UnnecessaryStringConcatSniff extends GenericUnnecessaryStringConcatSniff { /** * Processes this sniff, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { // Work out which type of file this is for. $tokens = $phpcsFile->getTokens(); @@ -58,7 +60,7 @@ class Drupal_Sniffs_Strings_UnnecessaryStringConcatSniff extends Generic_Sniffs_ return; } - $stringTokens = PHP_CodeSniffer_Tokens::$stringTokens; + $stringTokens = Tokens::$stringTokens; if (in_array($tokens[$prev]['code'], $stringTokens) === true && in_array($tokens[$next]['code'], $stringTokens) === true ) { @@ -77,7 +79,7 @@ class Drupal_Sniffs_Strings_UnnecessaryStringConcatSniff extends Generic_Sniffs_ // Before we throw an error check if the string is longer than // the line length limit. - $lineLengthLimitSniff = new Drupal_Sniffs_Files_LineLengthSniff; + $lineLengthLimitSniff = new LineLengthSniff; $lineLenght = $lineLengthLimitSniff->getLineLength($phpcsFile, $tokens[$prev]['line']); $stringLength = ($lineLenght + strlen($tokens[$next]['content']) - 4); diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php index 84753b3d5d0e7020b8358385dc06e7e9e67f4530..720ba3c6f5aeaf7ef1ad7fbf3271979fabe2b171 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php @@ -1,21 +1,28 @@ <?php /** - * Drupal_Sniffs_WhiteSpace_CloseBracketSpacingSniff. + * \Drupal\Sniffs\WhiteSpace\CloseBracketSpacingSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\WhiteSpace; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks that there is no white space before a closing bracket, for ")" and "}". - * Square Brackets are handled by Squiz_Sniffs_Arrays_ArrayBracketSpacingSniff. + * Square Brackets are handled by + * \PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayBracketSpacingSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_WhiteSpace_CloseBracketSpacingSniff implements PHP_CodeSniffer_Sniff +class CloseBracketSpacingSniff implements Sniff { /** @@ -48,13 +55,13 @@ class Drupal_Sniffs_WhiteSpace_CloseBracketSpacingSniff implements PHP_CodeSniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -68,7 +75,7 @@ class Drupal_Sniffs_WhiteSpace_CloseBracketSpacingSniff implements PHP_CodeSniff if (isset($tokens[($stackPtr - 1)]) === true && $tokens[($stackPtr - 1)]['code'] === T_WHITESPACE ) { - $before = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + $before = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($before !== false && $tokens[$stackPtr]['line'] === $tokens[$before]['line']) { $error = 'There should be no white space before a closing "%s"'; $fix = $phpcsFile->addFixableError( diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/CommaSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/CommaSniff.php index 87c069f3479f80db17752f5d5f56359bc5f7a9b7..69f1fba72dea46a1767ff4babef203c4d02786bf 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/CommaSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/CommaSniff.php @@ -1,14 +1,19 @@ <?php /** - * Drupal_Sniffs_WhiteSpace_CommaSniff. + * \Drupal\Sniffs\WhiteSpace\CommaSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\WhiteSpace; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** - * Drupal_Sniffs_WhiteSpace_CommaSniff. + * \Drupal\Sniffs\WhiteSpace\CommaSniff. * * Checks that there is one space after a comma. * @@ -16,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_WhiteSpace_CommaSniff implements PHP_CodeSniffer_Sniff +class CommaSniff implements Sniff { @@ -35,13 +40,13 @@ class Drupal_Sniffs_WhiteSpace_CommaSniff implements PHP_CodeSniffer_Sniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php index ae8fabf6dd9af22c9433bb7f445d7aaa952b706f..0d09618d98624dc378be22e148d92fdbdb202d67 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php @@ -1,14 +1,19 @@ <?php /** - * Drupal_Sniffs_WhiteSpace_EmptyLinesSniff. + * \Drupal\Sniffs\WhiteSpace\EmptyLinesSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\WhiteSpace; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** - * Drupal_Sniffs_WhiteSpace_EmptyLinesSniff. + * \Drupal\Sniffs\WhiteSpace\EmptyLinesSniff. * * Checks that there are not more than 2 empty lines following each other. * @@ -16,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_WhiteSpace_EmptyLinesSniff implements PHP_CodeSniffer_Sniff +class EmptyLinesSniff implements Sniff { /** @@ -46,13 +51,13 @@ class Drupal_Sniffs_WhiteSpace_EmptyLinesSniff implements PHP_CodeSniffer_Sniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); if ($tokens[$stackPtr]['content'] === $phpcsFile->eolChar diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/NamespaceSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/NamespaceSniff.php index 3da0e5ab73c3a060893056234634e4dc28893dfb..ddee5245051e8ea183c3f2db1a6af273e44f3f53 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/NamespaceSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/NamespaceSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_WhiteSpace_NamespaceSniff. + * \Drupal\Sniffs\WhiteSpace\NamespaceSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\WhiteSpace; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that there is exactly one space after the namespace keyword. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_WhiteSpace_NamespaceSniff implements PHP_CodeSniffer_Sniff +class NamespaceSniff implements Sniff { @@ -33,13 +38,13 @@ class Drupal_Sniffs_WhiteSpace_NamespaceSniff implements PHP_CodeSniffer_Sniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php index 50f20b9e6bb3951564e9f1a45e9a205609292112..ab72a1c098626355cc219d07d18022c163afc267 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php @@ -1,6 +1,6 @@ <?php /** - * Drupal_Sniffs_WhiteSpace_ObjectOperatorIndentSniff. + * \Drupal\Sniffs\WhiteSpace\ObjectOperatorIndentSniff. * * @category PHP * @package PHP_CodeSniffer @@ -10,8 +10,14 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\WhiteSpace; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** - * Drupal_Sniffs_WhiteSpace_ObjectOperatorIndentSniff. + * \Drupal\Sniffs\WhiteSpace\ObjectOperatorIndentSniff. * * Checks that object operators are indented 2 spaces if they are the first * thing on a line. @@ -24,7 +30,7 @@ * @version Release: 1.2.0RC3 * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_WhiteSpace_ObjectOperatorIndentSniff implements PHP_CodeSniffer_Sniff +class ObjectOperatorIndentSniff implements Sniff { @@ -43,13 +49,13 @@ class Drupal_Sniffs_WhiteSpace_ObjectOperatorIndentSniff implements PHP_CodeSnif /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile All the tokens found in the document. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -59,7 +65,7 @@ class Drupal_Sniffs_WhiteSpace_ObjectOperatorIndentSniff implements PHP_CodeSnif return; } - $previousLine = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 2), null, true, null, true); + $previousLine = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 2), null, true, null, true); if ($previousLine === false) { return; @@ -127,13 +133,13 @@ class Drupal_Sniffs_WhiteSpace_ObjectOperatorIndentSniff implements PHP_CodeSnif /** * Returns the first non whitespace token on the line. * - * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile All the tokens found in the document. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return int */ - protected function findStartOfline(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + protected function findStartOfline(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php index 3d42e2f68c38bc444113e90f62ed447d90f5c15b..ba787fd8910a0ce184e1262280aed32abc84b7a3 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php @@ -1,23 +1,30 @@ <?php /** - * Drupal_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff. + * \Drupal\Sniffs\WhiteSpace\ObjectOperatorSpacingSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\WhiteSpace; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Ensure that there are no white spaces before and after the object operator. * - * Largely copied from Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff but - * modified to not throw errors on multi line statements. + * Largely copied from + * \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ObjectOperatorSpacingSniff + * but modified to not throw errors on multi line statements. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff implements PHP_CodeSniffer_Sniff +class ObjectOperatorSpacingSniff implements Sniff { @@ -36,13 +43,13 @@ class Drupal_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff implements PHP_CodeSni /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) { @@ -68,7 +75,7 @@ class Drupal_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff implements PHP_CodeSni $phpcsFile->recordMetric($stackPtr, 'Spacing before object operator', $before); $phpcsFile->recordMetric($stackPtr, 'Spacing after object operator', $after); - $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); // Line breaks are allowed before an object operator. if ($before !== 0 && $tokens[$stackPtr]['line'] === $tokens[$prevToken]['line']) { $error = 'Space found before object operator'; diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php index 07c5b6e3c75ccc6381015babda42e9fc8c2e22bf..6c35ecf73ce42997e419574ecf16f9544a96168a 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php @@ -1,21 +1,27 @@ <?php /** - * Drupal_Sniffs_WhiteSpace_OpenBracketSpacingSniff. + * \Drupal\Sniffs\WhiteSpace\OpenBracketSpacingSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\WhiteSpace; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that there is no white space after an opening bracket, for "(" and "{". - * Square Brackets are handled by Squiz_Sniffs_Arrays_ArrayBracketSpacingSniff. + * Square Brackets are handled by + * \PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayBracketSpacingSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_WhiteSpace_OpenBracketSpacingSniff implements PHP_CodeSniffer_Sniff +class OpenBracketSpacingSniff implements Sniff { /** @@ -48,13 +54,13 @@ class Drupal_Sniffs_WhiteSpace_OpenBracketSpacingSniff implements PHP_CodeSniffe /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenTagNewlineSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenTagNewlineSniff.php index 6dfd7ec535bd136403dfc09f8e2d575f7d88cc5d..c4f4e7c5e3bb9beb3f07d8104595a897428ecd24 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenTagNewlineSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenTagNewlineSniff.php @@ -1,13 +1,17 @@ <?php - /** - * Drupal_Sniffs_WhiteSpace_OpenTagNewlineSniff. + * \Drupal\Sniffs\WhiteSpace\OpenTagNewlineSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\WhiteSpace; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that there is exactly one newline after the PHP open tag. * @@ -15,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_WhiteSpace_OpenTagNewlineSniff implements PHP_CodeSniffer_Sniff +class OpenTagNewlineSniff implements Sniff { @@ -34,15 +38,15 @@ class Drupal_Sniffs_WhiteSpace_OpenTagNewlineSniff implements PHP_CodeSniffer_Sn /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the - * token was found. - * @param int $stackPtr The position in the PHP_CodeSniffer - * file's token stack where the token - * was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where the + * token was found. + * @param int $stackPtr The position in the PHP_CodeSniffer + * file's token stack where the token + * was found. * * @return int End of the stack to skip the rest of the file. */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/OperatorSpacingSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/OperatorSpacingSniff.php index e705541dc4258418e74970db353867fcc796fc4e..92b851817a2532f6fed34d9cc5b6784f446c0467 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/OperatorSpacingSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/OperatorSpacingSniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_WhiteSpace_OperatorSpacingSniff. + * \Drupal\Sniffs\WhiteSpace\OperatorSpacingSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\WhiteSpace; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Overrides Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff to allow the plus operator * on numbers like "$i = +1;". @@ -15,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_WhiteSpace_OperatorSpacingSniff implements PHP_CodeSniffer_Sniff +class OperatorSpacingSniff implements Sniff { /** @@ -43,9 +49,9 @@ class Drupal_Sniffs_WhiteSpace_OperatorSpacingSniff implements PHP_CodeSniffer_S */ public function register() { - $comparison = PHP_CodeSniffer_Tokens::$comparisonTokens; - $operators = PHP_CodeSniffer_Tokens::$operators; - $assignment = PHP_CodeSniffer_Tokens::$assignmentTokens; + $comparison = Tokens::$comparisonTokens; + $operators = Tokens::$operators; + $assignment = Tokens::$assignmentTokens; $inlineIf = array( T_INLINE_THEN, T_INLINE_ELSE, @@ -61,13 +67,13 @@ class Drupal_Sniffs_WhiteSpace_OperatorSpacingSniff implements PHP_CodeSniffer_S /** * Processes this sniff, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The current file being checked. - * @param int $stackPtr The position of the current token in - * the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The current file being checked. + * @param int $stackPtr The position of the current token in + * the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -184,22 +190,22 @@ class Drupal_Sniffs_WhiteSpace_OperatorSpacingSniff implements PHP_CodeSniffer_S return; } - if (isset(PHP_CodeSniffer_Tokens::$operators[$tokens[$prev]['code']]) === true) { + if (isset(Tokens::$operators[$tokens[$prev]['code']]) === true) { // Just trying to operate on a negative value; eg. ($var * -1). return; } - if (isset(PHP_CodeSniffer_Tokens::$comparisonTokens[$tokens[$prev]['code']]) === true) { + if (isset(Tokens::$comparisonTokens[$tokens[$prev]['code']]) === true) { // Just trying to compare a negative value; eg. ($var === -1). return; } - if (isset(PHP_CodeSniffer_Tokens::$booleanOperators[$tokens[$prev]['code']]) === true) { + if (isset(Tokens::$booleanOperators[$tokens[$prev]['code']]) === true) { // Just trying to compare a negative value; eg. ($var || -1 === $b). return; } - if (isset(PHP_CodeSniffer_Tokens::$assignmentTokens[$tokens[$prev]['code']]) === true) { + if (isset(Tokens::$assignmentTokens[$tokens[$prev]['code']]) === true) { // Just trying to assign a negative value; eg. ($var = -1). return; } @@ -234,7 +240,7 @@ class Drupal_Sniffs_WhiteSpace_OperatorSpacingSniff implements PHP_CodeSniffer_S } $phpcsFile->recordMetric($stackPtr, 'Space before operator', 0); - } else if (isset(PHP_CodeSniffer_Tokens::$assignmentTokens[$tokens[$stackPtr]['code']]) === false) { + } else if (isset(Tokens::$assignmentTokens[$tokens[$stackPtr]['code']]) === false) { // Don't throw an error for assignments, because other standards allow // multiple spaces there to align multiple assignments. if ($tokens[($stackPtr - 2)]['line'] !== $tokens[$stackPtr]['line']) { diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index ab5d014286eef3a55aadb41d9223d5e60a25c3ac..a06da0e8a170374c1a417bd2dcfa94ff81d41d56 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -1,14 +1,20 @@ <?php /** - * Drupal_Sniffs_Whitespace_ScopeClosingBraceSniff. + * \Drupal\Sniffs\WhiteSpace\ScopeClosingBraceSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://Drupal.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\WhiteSpace; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Tokens; + /** - * Copied from PEAR_Sniffs_WhiteSpace_ScopeClosingBraceSniff to allow empty methods + * Copied from \PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ScopeClosingBraceSniff to allow empty methods * and classes. * * Checks that the closing braces of scopes are aligned correctly. @@ -17,7 +23,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer_Sniff +class ScopeClosingBraceSniff implements Sniff { /** @@ -35,7 +41,7 @@ class Drupal_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer */ public function register() { - return PHP_CodeSniffer_Tokens::$scopeOpeners; + return Tokens::$scopeOpeners; }//end register() @@ -43,13 +49,13 @@ class Drupal_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile All the tokens found in the document. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php index 2fff41dc391b07c3b322ff74f45726547322d19c..7c414eb9868a402726e471485ced4b35cea3885a 100644 --- a/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -1,15 +1,24 @@ <?php /** - * Drupal_Sniffs_Whitespace_ScopeIndentSniff. + * \Drupal\Sniffs\WhiteSpace\ScopeIndentSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace Drupal\Sniffs\WhiteSpace; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Util\Tokens; + /** - * Largely copied from Generic_Sniffs_Whitespace_ScopeIndentSniff, modified to make - * the exact mode working with comments and multi line statements. + * Largely copied from + * \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ScopeIndentSniff, + * modified to make the exact mode working with comments and multi line + * statements. * * Checks that control structures are structured correctly, and their content * is indented correctly. This sniff will throw errors if tabs are used @@ -19,7 +28,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff +class ScopeIndentSniff implements Sniff { /** @@ -120,28 +129,28 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile All the tokens found in the document. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { - $debug = PHP_CodeSniffer::getConfigData('scope_indent_debug'); + $debug = Config::getConfigData('scope_indent_debug'); if ($debug !== null) { $this->_debug = (bool) $debug; } if ($this->_tabWidth === null) { - $cliValues = $phpcsFile->phpcs->cli->getCommandLineValues(); - if (isset($cliValues['tabWidth']) === false || $cliValues['tabWidth'] === 0) { + $config = $phpcsFile->config; + if (isset($config->tabWidth) === false || $config->tabWidth === 0) { // We have no idea how wide tabs are, so assume 4 spaces for fixing. // It shouldn't really matter because indent checks elsewhere in the // standard should fix things up. $this->_tabWidth = 4; } else { - $this->_tabWidth = $cliValues['tabWidth']; + $this->_tabWidth = $config->tabWidth; } } @@ -718,7 +727,7 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff }//end if if ($checkToken !== null - && isset(PHP_CodeSniffer_Tokens::$scopeOpeners[$tokens[$checkToken]['code']]) === true + && isset(Tokens::$scopeOpeners[$tokens[$checkToken]['code']]) === true && in_array($tokens[$checkToken]['code'], $this->nonIndentingScopes) === false && isset($tokens[$checkToken]['scope_opener']) === true ) { @@ -768,7 +777,7 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff // Method prefix indentation has to be exact or else if will break // the rest of the function declaration, and potentially future ones. if ($checkToken !== null - && isset(PHP_CodeSniffer_Tokens::$methodPrefixes[$tokens[$checkToken]['code']]) === true + && isset(Tokens::$methodPrefixes[$tokens[$checkToken]['code']]) === true && $tokens[($checkToken + 1)]['code'] !== T_DOUBLE_COLON ) { $exact = true; @@ -820,7 +829,7 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff ) { if ($tokenIndent > $checkIndent) { // Ignore multi line statements. - $before = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($checkToken - 1), null, true); + $before = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($checkToken - 1), null, true); if ($before !== false && in_array( $tokens[$before]['code'], array( @@ -1065,7 +1074,7 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff } $condition = $tokens[$tokens[$i]['scope_condition']]['code']; - if (isset(PHP_CodeSniffer_Tokens::$scopeOpeners[$condition]) === true + if (isset(Tokens::$scopeOpeners[$condition]) === true && in_array($condition, $this->nonIndentingScopes) === false ) { if ($this->_debug === true) { @@ -1186,7 +1195,7 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff echo "\t* using parenthesis *".PHP_EOL; } - $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($parens - 1), null, true); + $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($parens - 1), null, true); $object = 0; $condition = 0; } else if ($object > 0 && $object >= $condition) { diff --git a/coder_sniffer/Drupal/Test/Array/ArrayUnitTest.inc b/coder_sniffer/Drupal/Test/Arrays/ArrayUnitTest.inc similarity index 100% rename from coder_sniffer/Drupal/Test/Array/ArrayUnitTest.inc rename to coder_sniffer/Drupal/Test/Arrays/ArrayUnitTest.inc diff --git a/coder_sniffer/Drupal/Test/Array/ArrayUnitTest.inc.fixed b/coder_sniffer/Drupal/Test/Arrays/ArrayUnitTest.inc.fixed similarity index 100% rename from coder_sniffer/Drupal/Test/Array/ArrayUnitTest.inc.fixed rename to coder_sniffer/Drupal/Test/Arrays/ArrayUnitTest.inc.fixed diff --git a/coder_sniffer/Drupal/Test/Array/ArrayUnitTest.php b/coder_sniffer/Drupal/Test/Arrays/ArrayUnitTest.php similarity index 81% rename from coder_sniffer/Drupal/Test/Array/ArrayUnitTest.php rename to coder_sniffer/Drupal/Test/Arrays/ArrayUnitTest.php index 15ef9082bab8b2d8478199a879ad4eab1bcf8445..5d9795149150abd24a57025cd22897cdc231c1d4 100644 --- a/coder_sniffer/Drupal/Test/Array/ArrayUnitTest.php +++ b/coder_sniffer/Drupal/Test/Arrays/ArrayUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Array_ArrayUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Arrays; + +use Drupal\Test\CoderSniffUnitTest; + +class ArrayUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Array_ArrayUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 13 => 1, @@ -32,7 +36,7 @@ class Drupal_Sniffs_Array_ArrayUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array( 17 => 1, diff --git a/coder_sniffer/Drupal/Test/Array/DisallowLongArraySyntaxUnitTest.php b/coder_sniffer/Drupal/Test/Arrays/DisallowLongArraySyntaxUnitTest.php similarity index 80% rename from coder_sniffer/Drupal/Test/Array/DisallowLongArraySyntaxUnitTest.php rename to coder_sniffer/Drupal/Test/Arrays/DisallowLongArraySyntaxUnitTest.php index fe97217fd713e015f3cdd538b051165e09a6dfe8..2d1b356e6b67e9cd88880b23a067e6cd27ce8ab3 100644 --- a/coder_sniffer/Drupal/Test/Array/DisallowLongArraySyntaxUnitTest.php +++ b/coder_sniffer/Drupal/Test/Arrays/DisallowLongArraySyntaxUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Array_DisallowLongArraySyntaxUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Arrays; + +use Drupal\Test\CoderSniffUnitTest; + +class DisallowLongArraySyntaxUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Array_DisallowLongArraySyntaxUnitTest extends CoderSniffUnit * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { switch ($testFile) { case 'DisallowLongArraySyntaxUnitTest.2.inc': @@ -32,7 +36,7 @@ class Drupal_Sniffs_Array_DisallowLongArraySyntaxUnitTest extends CoderSniffUnit * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); @@ -44,7 +48,7 @@ class Drupal_Sniffs_Array_DisallowLongArraySyntaxUnitTest extends CoderSniffUnit * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return array( __DIR__ . '/disallow_long_array_d7/DisallowLongArraySyntaxUnitTest.1.inc', __DIR__ . '/disallow_long_array_d8/DisallowLongArraySyntaxUnitTest.2.inc', diff --git a/coder_sniffer/Drupal/Test/Array/disallow_long_array_d7/DisallowLongArraySyntaxUnitTest.1.inc b/coder_sniffer/Drupal/Test/Arrays/disallow_long_array_d7/DisallowLongArraySyntaxUnitTest.1.inc similarity index 100% rename from coder_sniffer/Drupal/Test/Array/disallow_long_array_d7/DisallowLongArraySyntaxUnitTest.1.inc rename to coder_sniffer/Drupal/Test/Arrays/disallow_long_array_d7/DisallowLongArraySyntaxUnitTest.1.inc diff --git a/coder_sniffer/Drupal/Test/Array/disallow_long_array_d7/disallow_long_array_d7.info b/coder_sniffer/Drupal/Test/Arrays/disallow_long_array_d7/disallow_long_array_d7.info similarity index 100% rename from coder_sniffer/Drupal/Test/Array/disallow_long_array_d7/disallow_long_array_d7.info rename to coder_sniffer/Drupal/Test/Arrays/disallow_long_array_d7/disallow_long_array_d7.info diff --git a/coder_sniffer/Drupal/Test/Array/disallow_long_array_d8/DisallowLongArraySyntaxUnitTest.2.inc b/coder_sniffer/Drupal/Test/Arrays/disallow_long_array_d8/DisallowLongArraySyntaxUnitTest.2.inc similarity index 100% rename from coder_sniffer/Drupal/Test/Array/disallow_long_array_d8/DisallowLongArraySyntaxUnitTest.2.inc rename to coder_sniffer/Drupal/Test/Arrays/disallow_long_array_d8/DisallowLongArraySyntaxUnitTest.2.inc diff --git a/coder_sniffer/Drupal/Test/Array/disallow_long_array_d8/DisallowLongArraySyntaxUnitTest.2.inc.fixed b/coder_sniffer/Drupal/Test/Arrays/disallow_long_array_d8/DisallowLongArraySyntaxUnitTest.2.inc.fixed similarity index 100% rename from coder_sniffer/Drupal/Test/Array/disallow_long_array_d8/DisallowLongArraySyntaxUnitTest.2.inc.fixed rename to coder_sniffer/Drupal/Test/Arrays/disallow_long_array_d8/DisallowLongArraySyntaxUnitTest.2.inc.fixed diff --git a/coder_sniffer/Drupal/Test/Array/disallow_long_array_d8/disallow_long_array_d8.info.yml b/coder_sniffer/Drupal/Test/Arrays/disallow_long_array_d8/disallow_long_array_d8.info.yml similarity index 100% rename from coder_sniffer/Drupal/Test/Array/disallow_long_array_d8/disallow_long_array_d8.info.yml rename to coder_sniffer/Drupal/Test/Arrays/disallow_long_array_d8/disallow_long_array_d8.info.yml diff --git a/coder_sniffer/Drupal/Test/Classes/ClassCreateInstanceUnitTest.php b/coder_sniffer/Drupal/Test/Classes/ClassCreateInstanceUnitTest.php index d30627d8e3ac0419ded0d648578a5cd163a00db5..2d7b867a490bad05436f7343b143faaab4f59a39 100644 --- a/coder_sniffer/Drupal/Test/Classes/ClassCreateInstanceUnitTest.php +++ b/coder_sniffer/Drupal/Test/Classes/ClassCreateInstanceUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Classes_ClassCreateInstanceUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Classes; + +use Drupal\Test\CoderSniffUnitTest; + +class ClassCreateInstanceUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_Classes_ClassCreateInstanceUnitTest extends CoderSniffUnitTe * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 3 => 1, @@ -41,7 +45,7 @@ class Drupal_Sniffs_Classes_ClassCreateInstanceUnitTest extends CoderSniffUnitTe * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Classes/ClassDeclarationUnitTest.php b/coder_sniffer/Drupal/Test/Classes/ClassDeclarationUnitTest.php index 6e713def53c31c1f344df9476bdbb3c9d2601f4c..5a5b339e1f998a1bd8ca3c7f7a99885ad0e359df 100644 --- a/coder_sniffer/Drupal/Test/Classes/ClassDeclarationUnitTest.php +++ b/coder_sniffer/Drupal/Test/Classes/ClassDeclarationUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Classes_ClassDeclarationUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Classes; + +use Drupal\Test\CoderSniffUnitTest; + +class ClassDeclarationUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_Classes_ClassDeclarationUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 11 => 1, @@ -31,7 +35,7 @@ class Drupal_Sniffs_Classes_ClassDeclarationUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Classes/FullyQualifiedNamespaceUnitTest.php b/coder_sniffer/Drupal/Test/Classes/FullyQualifiedNamespaceUnitTest.php index 4a51b0166d284c510014759fd770dc918a0782a1..01012c03435aa0b220e31696e313be1045762fa7 100644 --- a/coder_sniffer/Drupal/Test/Classes/FullyQualifiedNamespaceUnitTest.php +++ b/coder_sniffer/Drupal/Test/Classes/FullyQualifiedNamespaceUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Classes_FullyQualifiedNamespaceUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Classes; + +use Drupal\Test\CoderSniffUnitTest;; + +class FullyQualifiedNamespaceUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_Classes_FullyQualifiedNamespaceUnitTest extends CoderSniffUn * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { switch ($testFile) { case 'FullyQualifiedNamespaceUnitTest.inc': @@ -34,7 +38,7 @@ class Drupal_Sniffs_Classes_FullyQualifiedNamespaceUnitTest extends CoderSniffUn * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); @@ -46,7 +50,7 @@ class Drupal_Sniffs_Classes_FullyQualifiedNamespaceUnitTest extends CoderSniffUn * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return [__DIR__.'/FullyQualifiedNamespaceUnitTest.inc', __DIR__.'/FullyQualifiedNamespaceUnitTest.api.php']; } diff --git a/coder_sniffer/Drupal/Test/Classes/PropertyDeclarationUnitTest.php b/coder_sniffer/Drupal/Test/Classes/PropertyDeclarationUnitTest.php index 051d6bb0d2c81a1a92bca7a34b08f4bb9aad3f07..043143aefc5a0287952e43926deffa3896d3a5c0 100644 --- a/coder_sniffer/Drupal/Test/Classes/PropertyDeclarationUnitTest.php +++ b/coder_sniffer/Drupal/Test/Classes/PropertyDeclarationUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Classes_PropertyDeclarationUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Classes; + +use Drupal\Test\CoderSniffUnitTest; + +class PropertyDeclarationUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_Classes_PropertyDeclarationUnitTest extends CoderSniffUnitTe * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(16 => 2); @@ -27,7 +31,7 @@ class Drupal_Sniffs_Classes_PropertyDeclarationUnitTest extends CoderSniffUnitTe * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Classes/UnusedUseStatementUnitTest.php b/coder_sniffer/Drupal/Test/Classes/UnusedUseStatementUnitTest.php index ab5078570c55f1c9cd1b86566dd2ad7f6436d288..7f09f148e372cb0805d5dff4a04ae08a29e1bb6f 100644 --- a/coder_sniffer/Drupal/Test/Classes/UnusedUseStatementUnitTest.php +++ b/coder_sniffer/Drupal/Test/Classes/UnusedUseStatementUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Classes_UnusedUseStatementUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Classes; + +use Drupal\Test\CoderSniffUnitTest; + +class UnusedUseStatementUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_Classes_UnusedUseStatementUnitTest extends CoderSniffUnitTes * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -27,7 +31,7 @@ class Drupal_Sniffs_Classes_UnusedUseStatementUnitTest extends CoderSniffUnitTes * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array( 5 => 1, diff --git a/coder_sniffer/Drupal/Test/Classes/UseLeadingBackslashUnitTest.php b/coder_sniffer/Drupal/Test/Classes/UseLeadingBackslashUnitTest.php index fab71a313b8f44251641708cf78a0d32ebd197f7..70f7c5fab92f1a0e08a3318c13404a6d73006a0d 100644 --- a/coder_sniffer/Drupal/Test/Classes/UseLeadingBackslashUnitTest.php +++ b/coder_sniffer/Drupal/Test/Classes/UseLeadingBackslashUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Classes_UseLeadingBackslashUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Classes; + +use Drupal\Test\CoderSniffUnitTest; + +class UseLeadingBackslashUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_Classes_UseLeadingBackslashUnitTest extends CoderSniffUnitTe * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(8 => 1); @@ -27,7 +31,7 @@ class Drupal_Sniffs_Classes_UseLeadingBackslashUnitTest extends CoderSniffUnitTe * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/CoderSniffUnitTest.php b/coder_sniffer/Drupal/Test/CoderSniffUnitTest.php index 4f883d5dba41941484f422d10bd2b017c10fd2d7..c5a948b976316aa3bf05528975bcd1bf86076f0d 100644 --- a/coder_sniffer/Drupal/Test/CoderSniffUnitTest.php +++ b/coder_sniffer/Drupal/Test/CoderSniffUnitTest.php @@ -1,22 +1,51 @@ <?php -/** - * An abstract class that all sniff unit tests must extend. - */ - /** * An abstract class that all sniff unit tests must extend. * - * This is a modified copy of AbstractSniffUnitTest used in PHP_CodeSniffer. + * A sniff unit test checks a .inc file for expected violations of a single + * coding standard. Expected errors and warnings that are not found, or + * warnings and errors that are not expected, are considered test failures. + * + * @author Greg Sherwood <gsherwood@squiz.net> + * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ -abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase + +namespace Drupal\Test; + +use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Files\LocalFile; +use PHP_CodeSniffer\RuntimeException; +use PHP_CodeSniffer\Util\Common; +use PHP_CodeSniffer\Autoload; +use PHP_CodeSniffer\Util\Tokens; + +abstract class CoderSniffUnitTest extends \PHPUnit_Framework_TestCase { /** - * The PHP_CodeSniffer object used for testing. + * Enable or disable the backup and restoration of the $GLOBALS array. + * Overwrite this attribute in a child class of TestCase. + * Setting this attribute in setUp() has no effect! + * + * @var boolean + */ + protected $backupGlobals = false; + + /** + * The path to the standard's main directory. + * + * @var string + */ + public $standardsDir = null; + + /** + * The path to the standard's test directory. * - * @var PHP_CodeSniffer + * @var string */ - protected static $phpcs = null; + public $testsDir = null; /** @@ -26,19 +55,54 @@ abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - if (!defined('PHP_CODESNIFFER_IN_TESTS')) { - define('PHP_CODESNIFFER_IN_TESTS', true); + $class = get_class($this); + + $this->rootDir = __DIR__ . '/../../'; + $this->testsDir = __DIR__.'/'; + $this->standardsDir = __DIR__.'/../'; + // Required to pull in all the defines from the tokens file. + $tokens = new Tokens(); + if (!defined('PHP_CODESNIFFER_VERBOSITY')) { + define('PHP_CODESNIFFER_VERBOSITY', 0); } - if (self::$phpcs === null) { - self::$phpcs = new PHP_CodeSniffer(0, 0, 'utf-8'); + if (!defined('PHP_CODESNIFFER_CBF')) { + define('PHP_CODESNIFFER_CBF', 0); } + }//end setUp() - // Make sure our sniffs are known by setting the additional installed paths. - $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA'] = [ - 'installed_paths' => dirname(dirname(__DIR__)), - ]; - }//end setUp() + /** + * Get a list of all test files to check. + * + * These will have the same base as the sniff name but different extensions. + * We ignore the .php file as it is the class. + * + * @param string $testFileBase The base path that the unit tests files will have. + * + * @return string[] + */ + protected function getTestFiles($testFileBase) + { + $testFiles = array(); + + $dir = substr($testFileBase, 0, strrpos($testFileBase, DIRECTORY_SEPARATOR)); + $di = new \DirectoryIterator($dir); + + foreach ($di as $file) { + $path = $file->getPathname(); + if (substr($path, 0, strlen($testFileBase)) === $testFileBase) { + if ($path !== $testFileBase.'php' && substr($path, -5) !== 'fixed') { + $testFiles[] = $path; + } + } + } + + // Put them in order. + sort($testFiles); + + return $testFiles; + + }//end getTestFiles() /** @@ -59,58 +123,96 @@ abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase * @return void * @throws PHPUnit_Framework_Error */ - public final function testSniff() + final public function testSniff() { // Skip this test if we can't run in this environment. if ($this->shouldSkipTest() === true) { $this->markTestSkipped(); } - $testFiles = $this->getTestFiles(); - $sniffCodes = $this->getSniffCodes(); + $sniffCode = Common::getSniffCode(get_class($this)); + list($standardName, $categoryName, $sniffName) = explode('.', $sniffCode); + + // In the case where we are running all the sniffs, the standard will + // be the root class name. + if ($this->allSniffCodes()) { + list($standardName) = explode('\\', get_class($this)); + } + + $testFileBase = $this->rootDir.$standardName.DIRECTORY_SEPARATOR.'Test'.DIRECTORY_SEPARATOR.$categoryName.DIRECTORY_SEPARATOR.$sniffName.'UnitTest.'; + + $this->standardsDir = $this->rootDir.$standardName.DIRECTORY_SEPARATOR; + // $testFileBase = $this->testsDir.$categoryName.DIRECTORY_SEPARATOR.$sniffName.'UnitTest.'; - // Determine the standard to be used from the class name. - $class_name_parts = explode('_', get_class($this)); - $standard = $class_name_parts[0]; + // Get a list of all test files to check. + $testFiles = $this->getTestFiles($testFileBase); + + $config = new Config(); + $config->cache = false; + $GLOBALS['PHP_CODESNIFFER_CONFIG'] = $config; + + // $config->standards = array($standardName); + $config->ignored = array(); + $config->standards = array($this->standardsDir); $failureMessages = array(); foreach ($testFiles as $testFile) { - self::$phpcs->initStandard("coder_sniffer/$standard", $sniffCodes); - $filename = basename($testFile); + // Setup to test the selected Sniff. + if ($this->allSniffCodes()) { + $config->sniffs = []; + } + else { + $config->sniffs = array($sniffCode); + } + $ruleset = new Ruleset($config); + $GLOBALS['PHP_CODESNIFFER_RULESET'] = $ruleset; + + $filename = basename($testFile); + $oldConfig = $config->getSettings(); try { - $cliValues = $this->getCliValues($filename); - self::$phpcs->cli->setCommandLineValues($cliValues); - $phpcsFile = self::$phpcs->processFile($testFile); - } catch (Exception $e) { + $this->setCliValues($filename, $config); + $phpcsFile = new LocalFile($testFile, $ruleset, $config); + $phpcsFile->process(); + } catch (RuntimeException $e) { $this->fail('An unexpected exception has been caught: '.$e->getMessage()); } $failures = $this->generateFailureMessages($phpcsFile); $failureMessages = array_merge($failureMessages, $failures); - // Attempt to fix the errors. - // Re-initialize the standard to use all sniffs for the fixer. - self::$phpcs->initStandard("coder_sniffer/$standard"); - self::$phpcs->cli->setCommandLineValues($cliValues); - $phpcsFile = self::$phpcs->processFile($testFile); - - $phpcsFile->fixer->fixFile(); - $fixable = $phpcsFile->getFixableCount(); - if ($fixable > 0) { - $failureMessages[] = "Failed to fix $fixable fixable violations in $filename"; - } + if ($phpcsFile->getFixableCount() > 0) { + // Reinit to use all sniffs. + $config->sniffs = []; + $ruleset = new Ruleset($config); + try { + $this->setCliValues($filename, $config); + $phpcsFile = new LocalFile($testFile, $ruleset, $config); + $phpcsFile->process(); + } catch (RuntimeException $e) { + $this->fail('An unexpected exception has been caught: '.$e->getMessage()); + } + // Attempt to fix the errors. + $phpcsFile->fixer->fixFile(); + $fixable = $phpcsFile->getFixableCount(); + if ($fixable > 0) { + $failureMessages[] = "Failed to fix $fixable fixable violations in $filename"; + } - // Check for a .fixed file to check for accuracy of fixes. - $fixedFile = $testFile.'.fixed'; - if (file_exists($fixedFile) === true) { - $diff = $phpcsFile->fixer->generateDiff($fixedFile); - if (trim($diff) !== '') { - $filename = basename($testFile); - $fixedFilename = basename($fixedFile); - $failureMessages[] = "Fixed version of $filename does not match expected version in $fixedFilename; the diff is\n$diff"; + // Check for a .fixed file to check for accuracy of fixes. + $fixedFile = $testFile.'.fixed'; + if (file_exists($fixedFile) === true) { + $diff = $phpcsFile->fixer->generateDiff($fixedFile); + if (trim($diff) !== '') { + $filename = basename($testFile); + $fixedFilename = basename($fixedFile); + $failureMessages[] = "Fixed version of $filename does not match expected version in $fixedFilename; the diff is\n$diff"; + } } } + + // Restore the config. + $config->setSettings($oldConfig); }//end foreach if (empty($failureMessages) === false) { @@ -119,50 +221,6 @@ abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase }//end testSniff() - /** - * Returns a list of test files that should be checked. - * - * @return array The list of test files. - */ - protected function getTestFiles() { - $rc = new ReflectionClass(get_class($this)); - // Cut off the "php" file extension of the test class file. - $testFileBase = substr($rc->getFileName(), 0, -3); - - // Get a list of all test files to check. These will have the same base - // name but different extensions. We ignore the .php file as it is the class. - $testFiles = array(); - - $dir = substr($testFileBase, 0, strrpos($testFileBase, DIRECTORY_SEPARATOR)); - $di = new DirectoryIterator($dir); - - foreach ($di as $file) { - $path = $file->getPathname(); - if (substr($path, 0, strlen($testFileBase)) === $testFileBase) { - if ($path !== $testFileBase.'php' && substr($path, -5) !== 'fixed') { - $testFiles[] = $path; - } - } - } - - // Get them in order. - sort($testFiles); - return $testFiles; - } - - /** - * Returns a list of sniff codes that should be checked in this test. - * - * @return array The list of sniff codes. - */ - protected function getSniffCodes() { - // The basis for determining file locations. - $basename = substr(get_class($this), 0, -8); - - // The code of the sniff we are testing. - $parts = explode('_', $basename); - return array($parts[0].'.'.$parts[2].'.'.$parts[3]); - } /** * Generate a list of test failures for a given sniffed file. @@ -172,7 +230,7 @@ abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase * @return array * @throws PHP_CodeSniffer_Exception */ - public function generateFailureMessages(PHP_CodeSniffer_File $file) + public function generateFailureMessages(LocalFile $file) { $testFile = $file->getFilename(); @@ -182,11 +240,11 @@ abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase $expectedWarnings = $this->getWarningList(basename($testFile)); if (is_array($expectedErrors) === false) { - throw new PHP_CodeSniffer_Exception('getErrorList() must return an array'); + throw new RuntimeException('getErrorList() must return an array'); } if (is_array($expectedWarnings) === false) { - throw new PHP_CodeSniffer_Exception('getWarningList() must return an array'); + throw new RuntimeException('getWarningList() must return an array'); } /* @@ -198,6 +256,8 @@ abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase $allProblems = array(); $failureMessages = array(); + $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'] = []; + $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'] = []; foreach ($foundErrors as $line => $lineErrors) { foreach ($lineErrors as $column => $errors) { @@ -218,6 +278,17 @@ abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase $errorsTemp = array(); foreach ($errors as $foundError) { $errorsTemp[] = $foundError['message'].' ('.$foundError['source'].')'; + + $source = $foundError['source']; + if (in_array($source, $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES']) === false) { + $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'][] = $source; + } + + if ($foundError['fixable'] === true + && in_array($source, $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES']) === false + ) { + $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'][] = $source; + } } $allProblems[$line]['found_errors'] = array_merge($foundErrorsTemp, $errorsTemp); @@ -300,16 +371,6 @@ abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase $expectedErrors = $problems['expected_errors']; $expectedWarnings = $problems['expected_warnings']; - - // Uncomment the following generate line error pairs for the bad unit - // test. - /*if ($numErrors) { - print "$line => " . $numErrors . ",\n"; - } - if ($numWarnings) { - print "$line => " . $numWarnings . ",\n"; - }*/ - $errors = ''; $foundString = ''; @@ -367,15 +428,16 @@ abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase /** * Get a list of CLI values to set before the file is tested. * - * @param string $filename The name of the file being tested. + * @param string $filename The name of the file being tested. + * @param \PHP_CodeSniffer\Config $config The config data for the run. * * @return array */ - public function getCliValues($filename) + public function setCliValues($filename, $config) { - return array(); + return; - }//end getCliValues() + }//end setCliValues() /** @@ -384,9 +446,9 @@ abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * - * @return array(int => int) + * @return array<int, int> */ - protected abstract function getErrorList($testFile); + abstract protected function getErrorList($testFile = NULL); /** @@ -397,7 +459,18 @@ abstract class CoderSniffUnitTest extends PHPUnit_Framework_TestCase * * @return array(int => int) */ - protected abstract function getWarningList($testFile); + abstract protected function getWarningList($testFile = NULL); + + + /** + * Returns a list of sniff codes that should be checked in this test. + * + * @return array The list of sniff codes. + */ + protected function allSniffCodes() { + return FALSE; + } + }//end class diff --git a/coder_sniffer/Drupal/Test/Commenting/ClassCommentUnitTest.php b/coder_sniffer/Drupal/Test/Commenting/ClassCommentUnitTest.php index b096084f0bca5220f314b53a9d39aff6e387d25c..d777c324781709ad17ec57be2f204ba8f8be9516 100644 --- a/coder_sniffer/Drupal/Test/Commenting/ClassCommentUnitTest.php +++ b/coder_sniffer/Drupal/Test/Commenting/ClassCommentUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Commenting_ClassCommentUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class ClassCommentUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Commenting_ClassCommentUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 8 => 1, @@ -28,7 +32,7 @@ class Drupal_Sniffs_Commenting_ClassCommentUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Commenting/DataTypeNamespaceUnitTest.php b/coder_sniffer/Drupal/Test/Commenting/DataTypeNamespaceUnitTest.php index 5e95816957a9e8012b578f11e0073e3d09d9a328..65f1f1e6a0a26a5c188404bf89eebb1caee43878 100644 --- a/coder_sniffer/Drupal/Test/Commenting/DataTypeNamespaceUnitTest.php +++ b/coder_sniffer/Drupal/Test/Commenting/DataTypeNamespaceUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Commenting_DataTypeNamespaceUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class DataTypeNamespaceUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Commenting_DataTypeNamespaceUnitTest extends CoderSniffUnitT * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 15 => 1, @@ -30,7 +34,7 @@ class Drupal_Sniffs_Commenting_DataTypeNamespaceUnitTest extends CoderSniffUnitT * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Commenting/DocCommentAlignmentUnitTest.php b/coder_sniffer/Drupal/Test/Commenting/DocCommentAlignmentUnitTest.php index 85277fc624362c24a6449c6fab1572e59e890455..7426326d8b6a0d0e9a2e3a4bc7b02af9336a5fb7 100644 --- a/coder_sniffer/Drupal/Test/Commenting/DocCommentAlignmentUnitTest.php +++ b/coder_sniffer/Drupal/Test/Commenting/DocCommentAlignmentUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Commenting_DocCommentAlignmentUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class DocCommentAlignmentUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Commenting_DocCommentAlignmentUnitTest extends CoderSniffUni * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 14 => 1, @@ -29,7 +33,7 @@ class Drupal_Sniffs_Commenting_DocCommentAlignmentUnitTest extends CoderSniffUni * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Commenting/DocCommentStarUnitTest.php b/coder_sniffer/Drupal/Test/Commenting/DocCommentStarUnitTest.php index 5a6104806653f38d0ce9987daabd48e3ed7319f6..dd4d8b89a20537584fb88093320ce30206a70543 100644 --- a/coder_sniffer/Drupal/Test/Commenting/DocCommentStarUnitTest.php +++ b/coder_sniffer/Drupal/Test/Commenting/DocCommentStarUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Commenting_DocCommentStarUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class DocCommentStarUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Commenting_DocCommentStarUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { switch ($testFile) { case 'DocCommentStarUnitTest.inc': @@ -34,7 +38,7 @@ class Drupal_Sniffs_Commenting_DocCommentStarUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.inc b/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.inc index 528720369bd3530e8de63771812db6fa4b65711f..f1348579bd58dd371b0f58fa56df7519d6b05fb9 100644 --- a/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.inc +++ b/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.inc @@ -96,3 +96,10 @@ function test12() { */ public function givenOrganisations(TableNode $organisation_table) { } + +/**+ + * This has a typo after the comment start. + */ +function test13() { + +} diff --git a/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.inc.fixed b/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.inc.fixed index d4f71d32f976aa328e25290ff0f6980950a5f866..0bacbcee43050f4f011a362b7702bbab982dbbaa 100644 --- a/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.inc.fixed +++ b/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.inc.fixed @@ -104,3 +104,11 @@ function test12() { */ public function givenOrganisations(TableNode $organisation_table) { } + +/** + * + + * This has a typo after the comment start. + */ +function test13() { + +} diff --git a/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.php b/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.php index b2db451505bc4c727d544453a6d58fecc95412f7..595802b5f0f9619b21c275e51f4ff1eb3025a9f1 100644 --- a/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.php +++ b/coder_sniffer/Drupal/Test/Commenting/DocCommentUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Commenting_DocCommentUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class DocCommentUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Commenting_DocCommentUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { switch ($testFile) { case 'DocCommentUnitTest.inc': @@ -24,6 +28,8 @@ class Drupal_Sniffs_Commenting_DocCommentUnitTest extends CoderSniffUnitTest 36 => 2, 45 => 1, 66 => 1, + 100 => 4, + 101 => 1, ); default: return array(); @@ -40,7 +46,7 @@ class Drupal_Sniffs_Commenting_DocCommentUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.10.inc b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.10.inc index 12f25187dbabf5a5d045d6f1fc1333fcecf3b416..ffb5ee9d46958112f7a5402e0ea692e1717ee9f1 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.10.inc +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.10.inc @@ -1,14 +1,7 @@ <?php - /** * @file */ - -namespace Blah; - -/** - * Bla. - */ -trait Pum { - +function foo_bar($foo) { + return NULL; } diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.10.inc.fixed b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.10.inc.fixed index 0a148ed87a688d0bb625b4b138b5c8702ade92a8..443fe4a7aeec8a85c33e92dae03eb1e76c428ef5 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.10.inc.fixed +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.10.inc.fixed @@ -1,10 +1,12 @@ <?php -namespace Blah; - /** - * Bla. + * @file */ -trait Pum { +/** + * + */ +function foo_bar($foo) { + return NULL; } diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.11.inc b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.11.inc index ffb5ee9d46958112f7a5402e0ea692e1717ee9f1..17bad8e35335acf4380ff8a801a97d673d7b0def 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.11.inc +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.11.inc @@ -2,6 +2,6 @@ /** * @file */ -function foo_bar($foo) { - return NULL; +class Foo { + } diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.11.inc.fixed b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.11.inc.fixed index 443fe4a7aeec8a85c33e92dae03eb1e76c428ef5..a188fc4705c45adbc7e5e06d39335f2a232f7ad6 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.11.inc.fixed +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.11.inc.fixed @@ -7,6 +7,6 @@ /** * */ -function foo_bar($foo) { - return NULL; +class Foo { + } diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.12.inc b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.12.inc deleted file mode 100644 index 17bad8e35335acf4380ff8a801a97d673d7b0def..0000000000000000000000000000000000000000 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.12.inc +++ /dev/null @@ -1,7 +0,0 @@ -<?php -/** - * @file - */ -class Foo { - -} diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.12.inc.fixed b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.12.inc.fixed deleted file mode 100644 index a188fc4705c45adbc7e5e06d39335f2a232f7ad6..0000000000000000000000000000000000000000 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.12.inc.fixed +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -/** - * @file - */ - -/** - * - */ -class Foo { - -} diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.5.inc b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.5.inc index 5d6d9264eddb5ab86917caebd6689b0d42ec1a59..b10b4cc49a05ed241492181e700797c2c1de55a9 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.5.inc +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.5.inc @@ -1,6 +1,6 @@ -<?php - -/**+ - * @file - * Typo after comment start. - */ +<nav aria-labelledby="breadcrumb_title" class="breadcrumb" role="navigation"> +<p class="hide" id="breadcrumb_title"><?php echo t('You are here'); ?> </p> + <ul class="breadcrumb"> + <li><?php echo implode('</li><li> ', $variables['breadcrumb']); ?></li> + </ul> +</nav> diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.5.inc.fixed b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.5.inc.fixed index 6d0cdda24fe0455f94ba23ca4fd2395149d17d37..5b0a7c669a862771c12367759463dbefcba06092 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.5.inc.fixed +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.5.inc.fixed @@ -2,7 +2,11 @@ /** * @file - * +. - * - * Typo after comment start. */ +?> +<nav aria-labelledby="breadcrumb_title" class="breadcrumb" role="navigation"> +<p class="hide" id="breadcrumb_title"><?php echo t('You are here'); ?> </p> + <ul class="breadcrumb"> + <li><?php echo implode('</li><li> ', $variables['breadcrumb']); ?></li> + </ul> +</nav> diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.6.inc b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.6.inc index b10b4cc49a05ed241492181e700797c2c1de55a9..7c2191957726d9e62d63af18878dd8f506f544e7 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.6.inc +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.6.inc @@ -1,6 +1,14 @@ -<nav aria-labelledby="breadcrumb_title" class="breadcrumb" role="navigation"> -<p class="hide" id="breadcrumb_title"><?php echo t('You are here'); ?> </p> - <ul class="breadcrumb"> - <li><?php echo implode('</li><li> ', $variables['breadcrumb']); ?></li> - </ul> -</nav> +<?php + +/** + * @file + */ + +namespace Blah; + +/** + * Bla. + */ +class Pum { + +} diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.6.inc.fixed b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.6.inc.fixed index 5b0a7c669a862771c12367759463dbefcba06092..364567a4d9de1454ab78047dfdf32bc19974d294 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.6.inc.fixed +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.6.inc.fixed @@ -1,12 +1,10 @@ <?php +namespace Blah; + /** - * @file + * Bla. */ -?> -<nav aria-labelledby="breadcrumb_title" class="breadcrumb" role="navigation"> -<p class="hide" id="breadcrumb_title"><?php echo t('You are here'); ?> </p> - <ul class="breadcrumb"> - <li><?php echo implode('</li><li> ', $variables['breadcrumb']); ?></li> - </ul> -</nav> +class Pum { + +} diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.7.inc b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.7.inc index 7c2191957726d9e62d63af18878dd8f506f544e7..941f59d3b22608104b7b5ef7f167e737a890ad16 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.7.inc +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.7.inc @@ -1,11 +1,5 @@ <?php -/** - * @file - */ - -namespace Blah; - /** * Bla. */ diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.7.inc.fixed b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.7.inc.fixed index 364567a4d9de1454ab78047dfdf32bc19974d294..941f59d3b22608104b7b5ef7f167e737a890ad16 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.7.inc.fixed +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.7.inc.fixed @@ -1,7 +1,5 @@ <?php -namespace Blah; - /** * Bla. */ diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.8.inc b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.8.inc index 941f59d3b22608104b7b5ef7f167e737a890ad16..e843c83a8f617c54941014ac8180834306e86e7e 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.8.inc +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.8.inc @@ -1,8 +1,14 @@ <?php +/** + * @file + */ + +namespace Blah; + /** * Bla. */ -class Pum { +interface Pum { } diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.8.inc.fixed b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.8.inc.fixed index 941f59d3b22608104b7b5ef7f167e737a890ad16..743f157480fa66ff964c3b8aa009eac018842d3d 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.8.inc.fixed +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.8.inc.fixed @@ -1,8 +1,10 @@ <?php +namespace Blah; + /** * Bla. */ -class Pum { +interface Pum { } diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.9.inc b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.9.inc index e843c83a8f617c54941014ac8180834306e86e7e..12f25187dbabf5a5d045d6f1fc1333fcecf3b416 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.9.inc +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.9.inc @@ -9,6 +9,6 @@ namespace Blah; /** * Bla. */ -interface Pum { +trait Pum { } diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.9.inc.fixed b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.9.inc.fixed index 743f157480fa66ff964c3b8aa009eac018842d3d..0a148ed87a688d0bb625b4b138b5c8702ade92a8 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.9.inc.fixed +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.9.inc.fixed @@ -5,6 +5,6 @@ namespace Blah; /** * Bla. */ -interface Pum { +trait Pum { } diff --git a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.php b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.php index 1de41cdcbcbe6e2fb7d09a66203435c0735e3ad5..202b31b3279c13b1a55873315b3281c329058951 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.php +++ b/coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Commenting_FileCommentUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class FileCommentUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Commenting_FileCommentUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { switch ($testFile) { case 'FileCommentUnitTest.inc': @@ -35,32 +39,28 @@ class Drupal_Sniffs_Commenting_FileCommentUnitTest extends CoderSniffUnitTest 3 => 1, ); case 'FileCommentUnitTest.5.inc': - return array( - 3 => 1, - ); - case 'FileCommentUnitTest.6.inc': return array( 1 => 1, ); - case 'FileCommentUnitTest.7.inc': + case 'FileCommentUnitTest.6.inc': return array( 3 => 1, ); - case 'FileCommentUnitTest.8.inc': + case 'FileCommentUnitTest.7.inc': return array(); - case 'FileCommentUnitTest.9.inc': + case 'FileCommentUnitTest.8.inc': return array( 3 => 1, ); - case 'FileCommentUnitTest.10.inc': + case 'FileCommentUnitTest.9.inc': return array( 3 => 1, ); - case 'FileCommentUnitTest.11.inc': + case 'FileCommentUnitTest.10.inc': return array( 4 => 1, ); - case 'FileCommentUnitTest.12.inc': + case 'FileCommentUnitTest.11.inc': return array( 4 => 1, ); @@ -77,7 +77,7 @@ class Drupal_Sniffs_Commenting_FileCommentUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Commenting/FunctionCommentUnitTest.php b/coder_sniffer/Drupal/Test/Commenting/FunctionCommentUnitTest.php index d38890312c492b60ee44165bc3fc25ac3bc09204..f492a00aa73d7196b66b0114b113f03e0a7b1ac1 100644 --- a/coder_sniffer/Drupal/Test/Commenting/FunctionCommentUnitTest.php +++ b/coder_sniffer/Drupal/Test/Commenting/FunctionCommentUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Commenting_FunctionCommentUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class FunctionCommentUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Commenting_FunctionCommentUnitTest extends CoderSniffUnitTes * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { switch ($testFile) { case 'FunctionCommentUnitTest.inc': @@ -83,7 +87,7 @@ class Drupal_Sniffs_Commenting_FunctionCommentUnitTest extends CoderSniffUnitTes * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Commenting/InlineCommentUnitTest.php b/coder_sniffer/Drupal/Test/Commenting/InlineCommentUnitTest.php index 96fa240083a3a3db11be27903d67e51d779b4d5a..e577f605ebc7e88464042cdbae61c21a05517145 100644 --- a/coder_sniffer/Drupal/Test/Commenting/InlineCommentUnitTest.php +++ b/coder_sniffer/Drupal/Test/Commenting/InlineCommentUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Commenting_InlineCommentUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class InlineCommentUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Commenting_InlineCommentUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 8 => 1, @@ -38,7 +42,7 @@ class Drupal_Sniffs_Commenting_InlineCommentUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array( 16 => 1, diff --git a/coder_sniffer/Drupal/Test/Commenting/PostStatementCommentUnitTest.php b/coder_sniffer/Drupal/Test/Commenting/PostStatementCommentUnitTest.php index a2be3e542112e366e58a43d1be59166c9ffe4025..be137af8e71fb31423d7409d6f985c296da3cb61 100644 --- a/coder_sniffer/Drupal/Test/Commenting/PostStatementCommentUnitTest.php +++ b/coder_sniffer/Drupal/Test/Commenting/PostStatementCommentUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Commenting_PostStatementCommentUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class PostStatementCommentUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Commenting_PostStatementCommentUnitTest extends CoderSniffUn * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { switch ($testFile) { case 'PostStatementCommentUnitTest.inc': @@ -36,7 +40,7 @@ class Drupal_Sniffs_Commenting_PostStatementCommentUnitTest extends CoderSniffUn * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Commenting/VariableCommentUnitTest.php b/coder_sniffer/Drupal/Test/Commenting/VariableCommentUnitTest.php index 3f6ffa3f64185e0ac90ca7d9da588f649fd551d1..340b878f0b278eb272a7f4fede54da1c6f6203f3 100644 --- a/coder_sniffer/Drupal/Test/Commenting/VariableCommentUnitTest.php +++ b/coder_sniffer/Drupal/Test/Commenting/VariableCommentUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Commenting_VariableCommentUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class VariableCommentUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Commenting_VariableCommentUnitTest extends CoderSniffUnitTes * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 16 => 1, @@ -32,7 +36,7 @@ class Drupal_Sniffs_Commenting_VariableCommentUnitTest extends CoderSniffUnitTes * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/ControlStructures/ControlSignatureUnitTest.php b/coder_sniffer/Drupal/Test/ControlStructures/ControlSignatureUnitTest.php index 721901c4ec8398230e0f689c470a064eca84413c..4dee5ff2db43faca1bec1c9bc0a66ce69fc13185 100644 --- a/coder_sniffer/Drupal/Test/ControlStructures/ControlSignatureUnitTest.php +++ b/coder_sniffer/Drupal/Test/ControlStructures/ControlSignatureUnitTest.php @@ -1,9 +1,13 @@ <?php +namespace Drupal\Sniffs\ControlStructures; + +use Drupal\Test\CoderSniffUnitTest; + /** - * Class Drupal_Sniffs_ControlStructures_ControlSignatureUnitTest + * Class ControlSignatureUnitTest */ -class Drupal_Sniffs_ControlStructures_ControlSignatureUnitTest extends CoderSniffUnitTest +class ControlSignatureUnitTest extends CoderSniffUnitTest { /** @@ -14,7 +18,7 @@ class Drupal_Sniffs_ControlStructures_ControlSignatureUnitTest extends CoderSnif * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 6 => 1, @@ -32,7 +36,7 @@ class Drupal_Sniffs_ControlStructures_ControlSignatureUnitTest extends CoderSnif * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/ControlStructures/ElseIfUnitTest.php b/coder_sniffer/Drupal/Test/ControlStructures/ElseIfUnitTest.php index ff99e715c630e3b8f0a029065423e3b5dc5f5cb1..2c50ba60cb0ed84031fa8b10f1e395f9d295cdbd 100644 --- a/coder_sniffer/Drupal/Test/ControlStructures/ElseIfUnitTest.php +++ b/coder_sniffer/Drupal/Test/ControlStructures/ElseIfUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_ControlStructures_ElseIfUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\ControlStructures; + +use Drupal\Test\CoderSniffUnitTest; + +class ElseIfUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_ControlStructures_ElseIfUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 6 => 1, @@ -29,7 +33,7 @@ class Drupal_Sniffs_ControlStructures_ElseIfUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Files/EndFileNewlineUnitTest.php b/coder_sniffer/Drupal/Test/Files/EndFileNewlineUnitTest.php index d6bbdcaebf6cb50a10d0c63588a2a2b4700e2e5b..cbd51c35698b259d42ba914f9151d90de818a3da 100644 --- a/coder_sniffer/Drupal/Test/Files/EndFileNewlineUnitTest.php +++ b/coder_sniffer/Drupal/Test/Files/EndFileNewlineUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Files_EndFileNewlineUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Files; + +use Drupal\Test\CoderSniffUnitTest; + +class EndFileNewlineUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_Files_EndFileNewlineUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { // All the good files have no error. if (strpos($testFile, 'good') !== false) { @@ -36,7 +40,7 @@ class Drupal_Sniffs_Files_EndFileNewlineUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Files/FileEncodingUnitTest.php b/coder_sniffer/Drupal/Test/Files/FileEncodingUnitTest.php index 1750cf8a3457a5ac906735656264c1a493e8ec3e..9b3b043dabe0a91cb939546acffdf954c75e6b71 100644 --- a/coder_sniffer/Drupal/Test/Files/FileEncodingUnitTest.php +++ b/coder_sniffer/Drupal/Test/Files/FileEncodingUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Tests_Files_FileEncodingUnitTest extends CoderSniffUnitTest +namespace PHP_CodeSniffer\Standards\Drupal\Tests\Files; + +use Drupal\Test\CoderSniffUnitTest; + +class FileEncodingUnitTest extends CoderSniffUnitTest { @@ -14,7 +18,7 @@ class Drupal_Tests_Files_FileEncodingUnitTest extends CoderSniffUnitTest * * @return array<int, int> */ - public function getErrorList($testFile='') + public function getErrorList($testFile = NULL) { return array(); @@ -31,7 +35,7 @@ class Drupal_Tests_Files_FileEncodingUnitTest extends CoderSniffUnitTest * * @return array<int, int> */ - public function getWarningList($testFile='') + public function getWarningList($testFile = NULL) { return array( 1 => 1, diff --git a/coder_sniffer/Drupal/Test/Files/LineLengthUnitTest.php b/coder_sniffer/Drupal/Test/Files/LineLengthUnitTest.php index 98739e9236d363609441ec67b64098ed475cbba9..e4fa6b4efe9caff5ad603de92a2eef7cda0e7ad5 100644 --- a/coder_sniffer/Drupal/Test/Files/LineLengthUnitTest.php +++ b/coder_sniffer/Drupal/Test/Files/LineLengthUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Files_LineLengthUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Files; + +use Drupal\Test\CoderSniffUnitTest; + +class LineLengthUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Files_LineLengthUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -26,7 +30,7 @@ class Drupal_Sniffs_Files_LineLengthUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Files/TxtFileLineLengthUnitTest.php b/coder_sniffer/Drupal/Test/Files/TxtFileLineLengthUnitTest.php index a288d2cf29e7ac6c4218e502477c02a00325e50b..6db34623019ce54f180051278c01a8a7a097bd81 100644 --- a/coder_sniffer/Drupal/Test/Files/TxtFileLineLengthUnitTest.php +++ b/coder_sniffer/Drupal/Test/Files/TxtFileLineLengthUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Files_TxtFileLineLengthUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Files; + +use Drupal\Test\CoderSniffUnitTest; + +class TxtFileLineLengthUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_Files_TxtFileLineLengthUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -27,7 +31,7 @@ class Drupal_Sniffs_Files_TxtFileLineLengthUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(1 => 1); diff --git a/coder_sniffer/Drupal/Test/Formatting/MultipleStatementAlignmentUnitTest.php b/coder_sniffer/Drupal/Test/Formatting/MultipleStatementAlignmentUnitTest.php index a7894bcb184040b2dcb2c968e3e0254082d3bea9..9d60d6df41e4530ac709992e3c3adc28b54a0a19 100644 --- a/coder_sniffer/Drupal/Test/Formatting/MultipleStatementAlignmentUnitTest.php +++ b/coder_sniffer/Drupal/Test/Formatting/MultipleStatementAlignmentUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Formatting_MultipleStatementAlignmentUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Formatting; + +use Drupal\Test\CoderSniffUnitTest; + +class MultipleStatementAlignmentUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Formatting_MultipleStatementAlignmentUnitTest extends CoderS * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 8 => 1, @@ -37,7 +41,7 @@ class Drupal_Sniffs_Formatting_MultipleStatementAlignmentUnitTest extends CoderS * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Formatting/SpaceUnaryOperatorUnitTest.php b/coder_sniffer/Drupal/Test/Formatting/SpaceUnaryOperatorUnitTest.php index e9f7dd50852141df4724bde16417be89b7fadbe4..5b46334be4f12c2e9ea5d14e97197a5c21a5067f 100644 --- a/coder_sniffer/Drupal/Test/Formatting/SpaceUnaryOperatorUnitTest.php +++ b/coder_sniffer/Drupal/Test/Formatting/SpaceUnaryOperatorUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Formatting_SpaceUnaryOperatorUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Formatting; + +use Drupal\Test\CoderSniffUnitTest; + +class SpaceUnaryOperatorUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_Formatting_SpaceUnaryOperatorUnitTest extends CoderSniffUnit * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 3 => 1, @@ -32,7 +36,7 @@ class Drupal_Sniffs_Formatting_SpaceUnaryOperatorUnitTest extends CoderSniffUnit * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/InfoFiles/AutoAddedKeysUnitTest.php b/coder_sniffer/Drupal/Test/InfoFiles/AutoAddedKeysUnitTest.php index 3fd23435ba6fef6ab0948f8bcde0ef1abdfa1507..99bd9ca5bb9dbc5310a5b570ea271d1a11870647 100644 --- a/coder_sniffer/Drupal/Test/InfoFiles/AutoAddedKeysUnitTest.php +++ b/coder_sniffer/Drupal/Test/InfoFiles/AutoAddedKeysUnitTest.php @@ -1,10 +1,14 @@ <?php +namespace Drupal\Sniffs\InfoFiles; + +use Drupal\Test\CoderSniffUnitTest; + /** * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class Drupal_Sniffs_InfoFiles_AutoAddedKeysUnitTest extends CoderSniffUnitTest +class AutoAddedKeysUnitTest extends CoderSniffUnitTest { @@ -16,7 +20,7 @@ class Drupal_Sniffs_InfoFiles_AutoAddedKeysUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -31,7 +35,7 @@ class Drupal_Sniffs_InfoFiles_AutoAddedKeysUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(1 => 3); @@ -41,8 +45,8 @@ class Drupal_Sniffs_InfoFiles_AutoAddedKeysUnitTest extends CoderSniffUnitTest * Returns a list of test files that should be checked. * * @return array The list of test files. - */ - protected function getTestFiles() { + ' */ + protected function getTestFiles($testFileBase) { return array(__DIR__ . '/test.info', __DIR__ . '/test.info.yml'); } diff --git a/coder_sniffer/Drupal/Test/InfoFiles/ClassFilesUnitTest.php b/coder_sniffer/Drupal/Test/InfoFiles/ClassFilesUnitTest.php index fb83816794e264ed4026ddc1fb2ec4911ef8c868..b1937eee80dd8bf08d2f5bbfe0e8298001ab63e3 100644 --- a/coder_sniffer/Drupal/Test/InfoFiles/ClassFilesUnitTest.php +++ b/coder_sniffer/Drupal/Test/InfoFiles/ClassFilesUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_InfoFiles_ClassFilesUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\InfoFiles; + +use Drupal\Test\CoderSniffUnitTest; + +class ClassFilesUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_InfoFiles_ClassFilesUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -27,7 +31,7 @@ class Drupal_Sniffs_InfoFiles_ClassFilesUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); @@ -38,7 +42,7 @@ class Drupal_Sniffs_InfoFiles_ClassFilesUnitTest extends CoderSniffUnitTest * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return array(__DIR__ . '/class_files.info'); } diff --git a/coder_sniffer/Drupal/Test/InfoFiles/DuplicateEntryUnitTest.php b/coder_sniffer/Drupal/Test/InfoFiles/DuplicateEntryUnitTest.php index 29aa7294e80d109820e1f3cb064c7c689d28c8da..f403eb2165ab7fee471f55c372a667c55bdc9b37 100644 --- a/coder_sniffer/Drupal/Test/InfoFiles/DuplicateEntryUnitTest.php +++ b/coder_sniffer/Drupal/Test/InfoFiles/DuplicateEntryUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace Drupal\Sniffs\InfoFiles; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the DuplicateEntry sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class Drupal_Sniffs_InfoFiles_DuplicateEntryUnitTest extends CoderSniffUnitTest +class DuplicateEntryUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class Drupal_Sniffs_InfoFiles_DuplicateEntryUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 1 => 1, @@ -35,7 +39,7 @@ class Drupal_Sniffs_InfoFiles_DuplicateEntryUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); @@ -46,7 +50,7 @@ class Drupal_Sniffs_InfoFiles_DuplicateEntryUnitTest extends CoderSniffUnitTest * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return array(__DIR__ . '/test.info'); } diff --git a/coder_sniffer/Drupal/Test/NamingConventions/ValidFunctionNameUnitTest.php b/coder_sniffer/Drupal/Test/NamingConventions/ValidFunctionNameUnitTest.php index 8fe2f7d8c17ed29cbe10de06893a0f04e21efaf9..401dc536b8a1ab326ca33850a62cd8d6c1c9286f 100644 --- a/coder_sniffer/Drupal/Test/NamingConventions/ValidFunctionNameUnitTest.php +++ b/coder_sniffer/Drupal/Test/NamingConventions/ValidFunctionNameUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_NamingConventions_ValidFunctionNameUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\NamingConventions; + +use Drupal\Test\CoderSniffUnitTest; + +class ValidFunctionNameUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_NamingConventions_ValidFunctionNameUnitTest extends CoderSni * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 3 => 1, @@ -30,7 +34,7 @@ class Drupal_Sniffs_NamingConventions_ValidFunctionNameUnitTest extends CoderSni * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/NamingConventions/ValidVariableNameUnitTest.php b/coder_sniffer/Drupal/Test/NamingConventions/ValidVariableNameUnitTest.php index 7766b37d4b17c6867411e8b62516b0e5e58425b3..6f4171c1e0b122ee00ffeb25bd19f48624f56511 100644 --- a/coder_sniffer/Drupal/Test/NamingConventions/ValidVariableNameUnitTest.php +++ b/coder_sniffer/Drupal/Test/NamingConventions/ValidVariableNameUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_NamingConventions_ValidVariableNameUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\NamingConventions; + +use Drupal\Test\CoderSniffUnitTest; + +class ValidVariableNameUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_NamingConventions_ValidVariableNameUnitTest extends CoderSni * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 3 => 1, @@ -28,7 +32,7 @@ class Drupal_Sniffs_NamingConventions_ValidVariableNameUnitTest extends CoderSni * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Scope/MethodScopeUnitTest.php b/coder_sniffer/Drupal/Test/Scope/MethodScopeUnitTest.php index 2e6e28ebc27856fd90cf5ba7f64cd8e9c6b725e2..f90c4497c9ad41f3221a70fe1796c7f70a918c69 100644 --- a/coder_sniffer/Drupal/Test/Scope/MethodScopeUnitTest.php +++ b/coder_sniffer/Drupal/Test/Scope/MethodScopeUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Scope_MethodScopeUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Scope; + +use Drupal\Test\CoderSniffUnitTest; + +class MethodScopeUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_Scope_MethodScopeUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 8 => 1, @@ -30,7 +34,7 @@ class Drupal_Sniffs_Scope_MethodScopeUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/Semantics/ConstantNameUnitTest.php b/coder_sniffer/Drupal/Test/Semantics/ConstantNameUnitTest.php index 756aa18f36fc477890fa1ec819d40212a08b1b33..c5adfe65726baaf40b8397a2f3eb9d331eb49fa7 100644 --- a/coder_sniffer/Drupal/Test/Semantics/ConstantNameUnitTest.php +++ b/coder_sniffer/Drupal/Test/Semantics/ConstantNameUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Semantics_ConstantNameUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Semantics; + +use Drupal\Test\CoderSniffUnitTest; + +class ConstantNameUnitTest extends CoderSniffUnitTest { @@ -9,7 +13,7 @@ class Drupal_Sniffs_Semantics_ConstantNameUnitTest extends CoderSniffUnitTest * * @return array The list of test files. */ - protected function getTestFiles() + protected function getTestFiles($testFileBase) { $dir = dirname(__FILE__); return array($dir.'/constant_test.install', $dir.'/constant_test.module'); @@ -25,7 +29,7 @@ class Drupal_Sniffs_Semantics_ConstantNameUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -40,7 +44,7 @@ class Drupal_Sniffs_Semantics_ConstantNameUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(3 => 1); diff --git a/coder_sniffer/Drupal/Test/Semantics/FunctionTUnitTest.php b/coder_sniffer/Drupal/Test/Semantics/FunctionTUnitTest.php index bf9de9fd6562d865bd9c200d7674d76ed1a94beb..4e68b69e989f940e6733ae726c956e7206b778c0 100644 --- a/coder_sniffer/Drupal/Test/Semantics/FunctionTUnitTest.php +++ b/coder_sniffer/Drupal/Test/Semantics/FunctionTUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Semantics_FunctionTUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Semantics; + +use Drupal\Test\CoderSniffUnitTest; + +class FunctionTUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_Semantics_FunctionTUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 29 => 1, @@ -29,7 +33,7 @@ class Drupal_Sniffs_Semantics_FunctionTUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array( 4 => 1, diff --git a/coder_sniffer/Drupal/Test/Semantics/FunctionWatchdogUnitTest.php b/coder_sniffer/Drupal/Test/Semantics/FunctionWatchdogUnitTest.php index e405cfc69dc8270f6ff319925397b36b7db8a2ab..9cdc5f5368ab003151dc79b32a524db698f44939 100644 --- a/coder_sniffer/Drupal/Test/Semantics/FunctionWatchdogUnitTest.php +++ b/coder_sniffer/Drupal/Test/Semantics/FunctionWatchdogUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_Semantics_FunctionWatchdogUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\Semantics; + +use Drupal\Test\CoderSniffUnitTest; + +class FunctionWatchdogUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class Drupal_Sniffs_Semantics_FunctionWatchdogUnitTest extends CoderSniffUnitTes * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(3 => 1); @@ -27,7 +31,7 @@ class Drupal_Sniffs_Semantics_FunctionWatchdogUnitTest extends CoderSniffUnitTes * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/WhiteSpace/CloseBracketSpacingUnitTest.php b/coder_sniffer/Drupal/Test/WhiteSpace/CloseBracketSpacingUnitTest.php index f5ac4f3b429523a5291fedfa74710db2908259dc..31ecfb34ef45ee3fa8697bedbd9e61f3ddf42584 100644 --- a/coder_sniffer/Drupal/Test/WhiteSpace/CloseBracketSpacingUnitTest.php +++ b/coder_sniffer/Drupal/Test/WhiteSpace/CloseBracketSpacingUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_WhiteSpace_CloseBracketSpacingUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\WhiteSpace; + +use Drupal\Test\CoderSniffUnitTest; + +class CloseBracketSpacingUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_WhiteSpace_CloseBracketSpacingUnitTest extends CoderSniffUni * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 3 => 1, @@ -29,7 +33,7 @@ class Drupal_Sniffs_WhiteSpace_CloseBracketSpacingUnitTest extends CoderSniffUni * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/WhiteSpace/CommaUnitTest.php b/coder_sniffer/Drupal/Test/WhiteSpace/CommaUnitTest.php index b052f9561c52e5bb8676cf85f455b08a61f03c4e..bbe9527ba857b9d15146fd90bd31a6a21c00858d 100644 --- a/coder_sniffer/Drupal/Test/WhiteSpace/CommaUnitTest.php +++ b/coder_sniffer/Drupal/Test/WhiteSpace/CommaUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_WhiteSpace_CommaUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\WhiteSpace; + +use Drupal\Test\CoderSniffUnitTest; + +class CommaUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_WhiteSpace_CommaUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 3 => 1, @@ -33,7 +37,7 @@ class Drupal_Sniffs_WhiteSpace_CommaUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/WhiteSpace/NamespaceUnitTest.php b/coder_sniffer/Drupal/Test/WhiteSpace/NamespaceUnitTest.php index f57a722e53de979a5ac72641c12b9e8972059ec0..47f0ffa54a6aa01120f00559c69576cee4d9f139 100644 --- a/coder_sniffer/Drupal/Test/WhiteSpace/NamespaceUnitTest.php +++ b/coder_sniffer/Drupal/Test/WhiteSpace/NamespaceUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_WhiteSpace_NamespaceUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\WhiteSpace; + +use Drupal\Test\CoderSniffUnitTest; + +class NamespaceUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_WhiteSpace_NamespaceUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 3 => 1, @@ -28,7 +32,7 @@ class Drupal_Sniffs_WhiteSpace_NamespaceUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/WhiteSpace/ObjectOperatorIndentUnitTest.php b/coder_sniffer/Drupal/Test/WhiteSpace/ObjectOperatorIndentUnitTest.php index 674b77e0fc599940868b59698ab11c6fa562fe76..4f0b1d5b9aec2b2d3d126c1606ed51bdb46e040a 100644 --- a/coder_sniffer/Drupal/Test/WhiteSpace/ObjectOperatorIndentUnitTest.php +++ b/coder_sniffer/Drupal/Test/WhiteSpace/ObjectOperatorIndentUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_WhiteSpace_ObjectOperatorIndentUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\WhiteSpace; + +use Drupal\Test\CoderSniffUnitTest; + +class ObjectOperatorIndentUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_WhiteSpace_ObjectOperatorIndentUnitTest extends CoderSniffUn * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 24 => 1, @@ -31,7 +35,7 @@ class Drupal_Sniffs_WhiteSpace_ObjectOperatorIndentUnitTest extends CoderSniffUn * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/WhiteSpace/ObjectOperatorSpacingUnitTest.php b/coder_sniffer/Drupal/Test/WhiteSpace/ObjectOperatorSpacingUnitTest.php index 1eee18c3455fa5b3c8c839e1b543c4efb53cff9f..b760b65aedc29f4387ba90f2b4d9b72632e57e8a 100644 --- a/coder_sniffer/Drupal/Test/WhiteSpace/ObjectOperatorSpacingUnitTest.php +++ b/coder_sniffer/Drupal/Test/WhiteSpace/ObjectOperatorSpacingUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_WhiteSpace_ObjectOperatorSpacingUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\WhiteSpace; + +use Drupal\Test\CoderSniffUnitTest; + +class ObjectOperatorSpacingUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_WhiteSpace_ObjectOperatorSpacingUnitTest extends CoderSniffU * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 9 => 1, @@ -29,7 +33,7 @@ class Drupal_Sniffs_WhiteSpace_ObjectOperatorSpacingUnitTest extends CoderSniffU * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/WhiteSpace/OpenBracketSpacingUnitTest.php b/coder_sniffer/Drupal/Test/WhiteSpace/OpenBracketSpacingUnitTest.php index a56847ecd8709bdb8f83ca7d7fe94a9b0e11fc36..515aaf5cc9e2a662c4a8f52bf949100f1a59c7a9 100644 --- a/coder_sniffer/Drupal/Test/WhiteSpace/OpenBracketSpacingUnitTest.php +++ b/coder_sniffer/Drupal/Test/WhiteSpace/OpenBracketSpacingUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_WhiteSpace_OpenBracketSpacingUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\WhiteSpace; + +use Drupal\Test\CoderSniffUnitTest; + +class OpenBracketSpacingUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_WhiteSpace_OpenBracketSpacingUnitTest extends CoderSniffUnit * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 3 => 1, @@ -29,7 +33,7 @@ class Drupal_Sniffs_WhiteSpace_OpenBracketSpacingUnitTest extends CoderSniffUnit * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/WhiteSpace/OpenTagNewlineUnitTest.php b/coder_sniffer/Drupal/Test/WhiteSpace/OpenTagNewlineUnitTest.php index 6d6f9cffcdabaca9d70cc65b870d5ed534453a4c..d9e6ac0d71b27c45b6caf0ed8906f81885e6a995 100644 --- a/coder_sniffer/Drupal/Test/WhiteSpace/OpenTagNewlineUnitTest.php +++ b/coder_sniffer/Drupal/Test/WhiteSpace/OpenTagNewlineUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_WhiteSpace_OpenTagNewlineUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\WhiteSpace; + +use Drupal\Test\CoderSniffUnitTest; + +class OpenTagNewlineUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_WhiteSpace_OpenTagNewlineUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 1 => 1, @@ -28,7 +32,7 @@ class Drupal_Sniffs_WhiteSpace_OpenTagNewlineUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/WhiteSpace/ScopeIndentUnitTest.php b/coder_sniffer/Drupal/Test/WhiteSpace/ScopeIndentUnitTest.php index 9478a8e218453f4977d9a7fc7ee258e54a4f1c95..26eb325628c04de6f36373bb79939ec777eb6860 100644 --- a/coder_sniffer/Drupal/Test/WhiteSpace/ScopeIndentUnitTest.php +++ b/coder_sniffer/Drupal/Test/WhiteSpace/ScopeIndentUnitTest.php @@ -1,6 +1,10 @@ <?php -class Drupal_Sniffs_WhiteSpace_ScopeIndentUnitTest extends CoderSniffUnitTest +namespace Drupal\Sniffs\WhiteSpace; + +use Drupal\Test\CoderSniffUnitTest; + +class ScopeIndentUnitTest extends CoderSniffUnitTest { /** @@ -11,7 +15,7 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 6 => 1, @@ -32,7 +36,7 @@ class Drupal_Sniffs_WhiteSpace_ScopeIndentUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); diff --git a/coder_sniffer/Drupal/Test/bad/BadUnitTest.php b/coder_sniffer/Drupal/Test/bad/BadUnitTest.php index 07a682379bedd72609dea4232743af693e9b6dc8..e930e3a80ba47de0e47b6a1a52ae408d3695991e 100644 --- a/coder_sniffer/Drupal/Test/bad/BadUnitTest.php +++ b/coder_sniffer/Drupal/Test/bad/BadUnitTest.php @@ -3,10 +3,14 @@ * Unit test class for all bad files. */ +namespace Drupal\bad; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for all bad files. */ -class Drupal_BadUnitTest extends CoderSniffUnitTest +class BadUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class Drupal_BadUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { switch ($testFile) { case 'bad.css': @@ -383,7 +387,7 @@ class Drupal_BadUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { switch ($testFile) { case 'bad.module': @@ -429,10 +433,10 @@ class Drupal_BadUnitTest extends CoderSniffUnitTest * * @return array The list of test files. */ - protected function getTestFiles() + protected function getTestFiles($testFileBase) { $dir = dirname(__FILE__); - $di = new DirectoryIterator($dir); + $di = new \DirectoryIterator($dir); foreach ($di as $file) { $path = $file->getPathname(); @@ -453,10 +457,10 @@ class Drupal_BadUnitTest extends CoderSniffUnitTest * * @return array The list of sniff codes. */ - protected function getSniffCodes() + protected function allSniffCodes() { // We want to test all sniffs defined in the standard. - return array(); + return TRUE; }//end getSniffCodes() diff --git a/coder_sniffer/Drupal/Test/good/GoodUnitTest.php b/coder_sniffer/Drupal/Test/good/GoodUnitTest.php index c5f9188a67c123c2d90ac178b4b1dbcb986d8a95..cd623ebbac45568caea05a0f410927451b542ab4 100644 --- a/coder_sniffer/Drupal/Test/good/GoodUnitTest.php +++ b/coder_sniffer/Drupal/Test/good/GoodUnitTest.php @@ -3,10 +3,14 @@ * Unit test class for all good files that must not throw errors/warnings. */ +namespace Drupal\good; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for all good files that must not throw errors/warnings. */ -class Drupal_GoodUnitTest extends CoderSniffUnitTest +class GoodUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class Drupal_GoodUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class Drupal_GoodUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); @@ -44,9 +48,9 @@ class Drupal_GoodUnitTest extends CoderSniffUnitTest * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { $dir = dirname(__FILE__); - $di = new DirectoryIterator($dir); + $di = new \DirectoryIterator($dir); foreach ($di as $file) { $path = $file->getPathname(); @@ -65,9 +69,9 @@ class Drupal_GoodUnitTest extends CoderSniffUnitTest * * @return array The list of sniff codes. */ - protected function getSniffCodes() { + protected function allSniffCodes() { // We want to test all sniffs defined in the standard. - return array(); + return TRUE; } diff --git a/coder_sniffer/Drupal/Test/phpunit-bootstrap.php b/coder_sniffer/Drupal/Test/phpunit-bootstrap.php index 0b7572eba466cfac74e5e3875b78cd86046cd97e..233c9cd212486c08cef508805a711647ef144e28 100644 --- a/coder_sniffer/Drupal/Test/phpunit-bootstrap.php +++ b/coder_sniffer/Drupal/Test/phpunit-bootstrap.php @@ -2,3 +2,4 @@ require 'vendor/autoload.php'; require 'CoderSniffUnitTest.php'; +require 'vendor/squizlabs/php_codesniffer/autoload.php'; diff --git a/coder_sniffer/Drupal/ruleset.xml b/coder_sniffer/Drupal/ruleset.xml index 5e2b0d98db34199350cf1510b384f83d14ea41b7..ba8d5d795028e733dc4aa1d9832489e215b3c2df 100644 --- a/coder_sniffer/Drupal/ruleset.xml +++ b/coder_sniffer/Drupal/ruleset.xml @@ -110,6 +110,9 @@ <rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine"> <severity>0</severity> </rule> + <rule ref="PEAR.Functions.FunctionCallSignature.OpeningIndent"> + <severity>0</severity> + </rule> <rule ref="PEAR.Functions.ValidDefaultValue" /> diff --git a/coder_sniffer/DrupalPractice/Project.php b/coder_sniffer/DrupalPractice/Project.php index 14871d755abd6533ff7f7a3ec0a5954e210b8401..45923bcee150c914d2011363d948b0a26e8d8476 100644 --- a/coder_sniffer/DrupalPractice/Project.php +++ b/coder_sniffer/DrupalPractice/Project.php @@ -1,12 +1,16 @@ <?php /** - * DrupalPractice_Project + * \DrupalPractice\Project * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice; + +use PHP_CodeSniffer\Files\File; +use \Drupal\Sniffs\InfoFiles\ClassFilesSniff; use Symfony\Component\Yaml\Yaml; /** @@ -16,19 +20,19 @@ use Symfony\Component\Yaml\Yaml; * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Project +class Project { /** * Determines the project short name a file might be associated with. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. * * @return string|false Returns the project machine name or false if it could not * be derived. */ - public static function getName(PHP_CodeSniffer_File $phpcsFile) + public static function getName(File $phpcsFile) { // Cache the project name per file as this might get called often. static $cache; @@ -60,12 +64,12 @@ class DrupalPractice_Project /** * Determines the info file a file might be associated with. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. * * @return string|false The project info file name or false if it could not * be derived. */ - public static function getInfoFile(PHP_CodeSniffer_File $phpcsFile) + public static function getInfoFile(File $phpcsFile) { // Cache the project name per file as this might get called often. static $cache; @@ -95,7 +99,7 @@ class DrupalPractice_Project } // Sort the info file names and take the shortest info file. - usort($infoFiles, array('DrupalPractice_Project', 'compareLength')); + usort($infoFiles, array(__NAMESPACE__.'\Project', 'compareLength')); $infoFile = $infoFiles[0]; $cache[$phpcsFile->getFilename()] = $infoFile; return $infoFile; @@ -106,12 +110,12 @@ class DrupalPractice_Project /** * Determines the *.services.yml file in a module. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. * * @return string|false The Services YML file name or false if it could not * be derived. */ - public static function getServicesYmlFile(PHP_CodeSniffer_File $phpcsFile) + public static function getServicesYmlFile(File $phpcsFile) { // Cache the services file per file as this might get called often. static $cache; @@ -138,7 +142,7 @@ class DrupalPractice_Project } // Sort the YML file names and take the shortest info file. - usort($ymlFiles, array('DrupalPractice_Project', 'compareLength')); + usort($ymlFiles, array(__NAMESPACE__.'\Project', 'compareLength')); $ymlFile = $ymlFiles[0]; $cache[$phpcsFile->getFilename()] = $ymlFile; return $ymlFile; @@ -149,13 +153,13 @@ class DrupalPractice_Project /** * Return true if the given class is a Drupal service registered in *.services.yml. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $classPtr The position of the class declaration - * in the token stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $classPtr The position of the class declaration + * in the token stack. * * @return bool */ - public static function isServiceClass(PHP_CodeSniffer_File $phpcsFile, $classPtr) + public static function isServiceClass(File $phpcsFile, $classPtr) { // Cache the information per file as this might get called often. static $cache; @@ -228,12 +232,12 @@ class DrupalPractice_Project /** * Determines the Drupal core version a file might be associated with. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. * * @return string|false The core version string or false if it could not * be derived. */ - public static function getCoreVersion(PHP_CodeSniffer_File $phpcsFile) + public static function getCoreVersion(File $phpcsFile) { $infoFile = static::getInfoFile($phpcsFile); if ($infoFile === false) { @@ -244,7 +248,7 @@ class DrupalPractice_Project // Drupal 6 and 7 use the .info file extension. if ($pathParts['extension'] === 'info') { - $info_settings = Drupal_Sniffs_InfoFiles_ClassFilesSniff::drupalParseInfoFormat(file_get_contents($infoFile)); + $info_settings = ClassFilesSniff::drupalParseInfoFormat(file_get_contents($infoFile)); if (isset($info_settings['core']) === true) { return $info_settings['core']; } diff --git a/coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php b/coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php index 980021eb2d678145b3fb56645b38baa3197a1ed3..0ed2cd213fe759c3ff53d3e3440193a0f3f49b04 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php @@ -10,6 +10,11 @@ * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\CodeAnalysis; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Holds details of a scope. * @@ -103,7 +108,7 @@ class VariableInfo * @copyright 2011 Sam Graham <php-codesniffer-variableanalysis BLAHBLAH illusori.co.uk> * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_CodeSniffer_Sniff +class VariableAnalysisSniff implements Sniff { /** * The current phpcsFile being checked. @@ -606,13 +611,13 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; @@ -897,14 +902,14 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Marks a variable as read and throws a PHPCS warning if it is undefined. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param string $varName - * @param int $stackPtr - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param string $varName + * @param int $stackPtr + * @param string $currScope * * @return bool */ - function markVariableReadAndWarnIfUndefined(PHP_CodeSniffer_File $phpcsFile, $varName, $stackPtr, $currScope) + function markVariableReadAndWarnIfUndefined(File $phpcsFile, $varName, $stackPtr, $currScope) { $this->markVariableRead($varName, $stackPtr, $currScope); @@ -926,12 +931,12 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Returns the function declaration pointer. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr * * @return int|false */ - function findFunctionPrototype(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + function findFunctionPrototype(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -969,12 +974,12 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Find the scope the given pointer is in. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr * * @return int|false */ - function findVariableScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + function findVariableScope(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; @@ -1010,12 +1015,12 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Checks if the next token is an assignment. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr * * @return bool */ - function isNextThingAnAssign(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + function isNextThingAnAssign(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -1041,12 +1046,12 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Find the end of the assignment. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr * * @return int */ - function findWhereAssignExecuted(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + function findWhereAssignExecuted(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -1085,12 +1090,12 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Find the parenthesis if the pointer is in some. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr * * @return int|false */ - function findContainingBrackets(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + function findContainingBrackets(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -1107,12 +1112,12 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Checks if the given pointer is in a function call. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr * * @return int|false */ - function findFunctionCall(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + function findFunctionCall(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -1139,12 +1144,12 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Get the arguments of a function call. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr * * @return array|false */ - function findFunctionCallArguments(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + function findFunctionCallArguments(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -1199,15 +1204,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Checks the function prototype. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForFunctionPrototype( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1320,15 +1325,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Checks if we are in a catch() block. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForCatchBlock( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1375,15 +1380,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Checks if $this is used within a class. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForThisWithinClass( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1410,15 +1415,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Checks if the variable is a PHP super global. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForSuperGlobal( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1455,15 +1460,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Checks if the variable is a static class member. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForStaticMember( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1535,15 +1540,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Checks if the variable is being assigned to. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForAssignment( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1578,15 +1583,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Check if this is a list language construct assignment. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForListAssignment( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1620,15 +1625,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Check if this variable is declared globally. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForGlobalDeclaration( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1667,15 +1672,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Check is this is a static variable declaration. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForStaticDeclaration( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1759,15 +1764,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Check if this is a foreach loop variable. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForForeachLoopVar( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1809,15 +1814,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Check if this is a "&" function call. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForPassByReferenceFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1890,15 +1895,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Check if the variable is an object property. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param string $varName - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param string $varName + * @param string $currScope * * @return bool */ protected function checkForSymbolicObjectProperty( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $varName, $currScope @@ -1929,14 +1934,14 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Called to process class member vars. * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this - * token was found. - * @param int $stackPtr The position where the token was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this + * token was found. + * @param int $stackPtr The position where the token was found. * * @return void */ protected function processMemberVar( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr ) { // TODO: don't care for now. @@ -1949,14 +1954,14 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Called to process normal member vars. * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this - * token was found. - * @param int $stackPtr The position where the token was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this + * token was found. + * @param int $stackPtr The position where the token was found. * * @return void */ protected function processVariable( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr ) { $tokens = $phpcsFile->getTokens(); @@ -2065,15 +2070,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co * Note that there may be more than one variable in the string, which will * result only in one call for the string. * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this - * token was found. - * @param int $stackPtr The position where the double quoted - * string was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this + * token was found. + * @param int $stackPtr The position where the double quoted + * string was found. * * @return void */ protected function processVariableInString( - PHP_CodeSniffer_File + File $phpcsFile, $stackPtr ) { @@ -2106,15 +2111,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Check variables in a compact() call. * - * @param PHP_CodeSniffer_File $phpcsFile - * @param int $stackPtr - * @param array $arguments - * @param string $currScope + * @param \PHP_CodeSniffer\Files\File $phpcsFile + * @param int $stackPtr + * @param array $arguments + * @param string $currScope * * @return void */ protected function processCompactArguments( - PHP_CodeSniffer_File + File $phpcsFile, $stackPtr, $arguments, @@ -2182,15 +2187,15 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co /** * Called to process variables named in a call to compact(). * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this - * token was found. - * @param int $stackPtr The position where the call to compact() - * was found. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this + * token was found. + * @param int $stackPtr The position where the call to compact() + * was found. * * @return void */ protected function processCompact( - PHP_CodeSniffer_File + File $phpcsFile, $stackPtr ) { @@ -2212,14 +2217,14 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff implements PHP_Co * Note that although triggered by the closing curly brace of the scope, $stackPtr is * the scope conditional, not the closing curly brace. * - * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this - * token was found. - * @param int $stackPtr The position of the scope conditional. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this + * token was found. + * @param int $stackPtr The position of the scope conditional. * * @return void */ protected function processScopeClose( - PHP_CodeSniffer_File + File $phpcsFile, $stackPtr ) { diff --git a/coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php index f9c7dc1399016a366133825513ffb8d661a3b04b..df78d6df195c76469a2a109bd7d24c60324c6d00 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Commenting/AuthorTagSniff.php @@ -1,12 +1,17 @@ <?php /** - * DrupalPractice_Sniffs_Commenting_AuthorTagSniff. + * \DrupalPractice\Sniffs\Commenting\AuthorTagSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks the usage of @author tags. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_Commenting_AuthorTagSniff implements PHP_CodeSniffer_Sniff +class AuthorTagSniff implements Sniff { @@ -33,13 +38,13 @@ class DrupalPractice_Sniffs_Commenting_AuthorTagSniff implements PHP_CodeSniffer /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/DrupalPractice/Sniffs/Commenting/CommentEmptyLineSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Commenting/CommentEmptyLineSniff.php index 1ffd149b017c535af2a904db0282557cee225704..0cb4e96e0f3647a86022c551b473ee5b9e96885a 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Commenting/CommentEmptyLineSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Commenting/CommentEmptyLineSniff.php @@ -1,13 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_Commenting_CommentEmptyLineSniff + * \DrupalPractice\Sniffs\Commenting\CommentEmptyLineSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Throws a warning if there is a blank line after an inline comment. * @@ -15,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_Commenting_CommentEmptyLineSniff implements PHP_CodeSniffer_Sniff +class CommentEmptyLineSniff implements Sniff { @@ -34,13 +39,13 @@ class DrupalPractice_Sniffs_Commenting_CommentEmptyLineSniff implements PHP_Code /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php index abf6f3a28a9a8238885d09de0ba15b5cefb4281f..e1a85e10ffc58a407cbaa8ddbe9fe8000701695a 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php @@ -1,12 +1,17 @@ <?php /** - * DrupalPractice_Sniffs_Commenting_ExpectedExceptionSniff. + * \DrupalPractice\Sniffs\Commenting\ExpectedExceptionSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\Commenting; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that the PHPunit @expectedExcpetion tags are not used. * @@ -16,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_Commenting_ExpectedExceptionSniff implements PHP_CodeSniffer_Sniff +class ExpectedExceptionSniff implements Sniff { @@ -35,13 +40,13 @@ class DrupalPractice_Sniffs_Commenting_ExpectedExceptionSniff implements PHP_Cod /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalConstantSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalConstantSniff.php index b0284dc4526bb1523c9aead5669212cfd68d1911..9e40e495fed489fec347cc27b3cac541134ff0a8 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalConstantSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalConstantSniff.php @@ -1,12 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_Constants_GlobalConstantSniff + * \DrupalPractice\Sniffs\Constants\GlobalConstantSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\Constants; + +use DrupalPractice\Project; +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that globally defined constants are not used in Drupal 8 and higher. * @@ -14,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_Constants_GlobalConstantSniff implements PHP_CodeSniffer_Sniff +class GlobalConstantSniff implements Sniff { @@ -33,13 +39,13 @@ class DrupalPractice_Sniffs_Constants_GlobalConstantSniff implements PHP_CodeSni /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The current file being processed. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -48,7 +54,7 @@ class DrupalPractice_Sniffs_Constants_GlobalConstantSniff implements PHP_CodeSni return; } - $coreVersion = DrupalPractice_Project::getCoreVersion($phpcsFile); + $coreVersion = Project::getCoreVersion($phpcsFile); if ($coreVersion !== '8.x') { return; } diff --git a/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalDefineSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalDefineSniff.php index ef7cf7e785def17b7c320e7f75f83b544bc6b7fb..20fb979b5877192d7d88d540d60ef27869d6e597 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalDefineSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Constants/GlobalDefineSniff.php @@ -1,12 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_Constants_GlobalDefineSniff + * \DrupalPractice\Sniffs\Constants\GlobalDefineSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\Constants; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; +use DrupalPractice\Project; + /** * Checks that global define() constants are not used in modules in Drupal 8. * @@ -14,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_Constants_GlobalDefineSniff extends Drupal_Sniffs_Semantics_FunctionCall +class GlobalDefineSniff extends FunctionCall { @@ -33,18 +39,18 @@ class DrupalPractice_Sniffs_Constants_GlobalDefineSniff extends Drupal_Sniffs_Se /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket @@ -56,7 +62,7 @@ class DrupalPractice_Sniffs_Constants_GlobalDefineSniff extends Drupal_Sniffs_Se return; } - $coreVersion = DrupalPractice_Project::getCoreVersion($phpcsFile); + $coreVersion = Project::getCoreVersion($phpcsFile); if ($coreVersion !== '8.x') { return; } diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CheckPlainSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CheckPlainSniff.php index 64eeb0bb36daf079661ea301c4cd6b792937eea5..438a3833f325638c9ab5fafcd742b2bfd4f8bcba 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CheckPlainSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CheckPlainSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_FunctionCalls_CheckPlainSniff + * \DrupalPractice\Sniffs\FunctionCalls\CheckPlainSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; + /** * Check that check_plain() is not used on literal strings. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionCalls_CheckPlainSniff extends Drupal_Sniffs_Semantics_FunctionCall +class CheckPlainSniff extends FunctionCall { @@ -33,18 +38,18 @@ class DrupalPractice_Sniffs_FunctionCalls_CheckPlainSniff extends Drupal_Sniffs_ /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CurlSslVerifierSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CurlSslVerifierSniff.php index da4d764f62674dfea460b1d13e40d7191c3ac03a..14bc814f14fe13cd26fd99a1ed4257c36e66f04f 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CurlSslVerifierSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/CurlSslVerifierSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_FunctionCalls_CurlSslVerifierSniff + * \DrupalPractice\Sniffs\FunctionCalls\CurlSslVerifierSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; + /** * Make sure that CURLOPT_SSL_VERIFYPEER is not disabled, since that is a * security issue. @@ -15,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionCalls_CurlSslVerifierSniff extends Drupal_Sniffs_Semantics_FunctionCall +class CurlSslVerifierSniff extends FunctionCall { @@ -34,18 +39,18 @@ class DrupalPractice_Sniffs_FunctionCalls_CurlSslVerifierSniff extends Drupal_Sn /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbQuerySniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbQuerySniff.php index c571f4efe697aa2771e362997861a2bce5d356af..e08a5291ee7e7450530d4db7c6091880c90d029d 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbQuerySniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbQuerySniff.php @@ -1,12 +1,18 @@ <?php /** - * Drupal_Sniffs_FunctionCalls_DbQuerySniff + * \DrupalPractice\Sniffs\FunctionCalls\DbQuerySniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; +use DrupalPractice\Project; + /** * Check that UPDATE/DELETE queries are not used in db_query() in Drupal 7. * @@ -14,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionCalls_DbQuerySniff extends Drupal_Sniffs_Semantics_FunctionCall +class DbQuerySniff extends FunctionCall { @@ -33,24 +39,24 @@ class DrupalPractice_Sniffs_FunctionCalls_DbQuerySniff extends Drupal_Sniffs_Sem /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket ) { // This check only applies to Drupal 7, not Drupal 6. - if (DrupalPractice_Project::getCoreVersion($phpcsFile) !== '7.x') { + if (Project::getCoreVersion($phpcsFile) !== '7.x') { return; } diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbSelectBracesSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbSelectBracesSniff.php index 50832688255356a9567487338d957ade96e581d7..fe9704d0e84510088086fbab0b27ba3ecd1975a4 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbSelectBracesSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DbSelectBracesSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_FunctionCalls_DbSelectBracesSniff + * \DrupalPractice\Sniffs\FunctionCalls\DbSelectBracesSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; + /** * Check that db_select() calls do not use {} braces for the table name. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionCalls_DbSelectBracesSniff extends Drupal_Sniffs_Semantics_FunctionCall +class DbSelectBracesSniff extends FunctionCall { @@ -33,18 +38,18 @@ class DrupalPractice_Sniffs_FunctionCalls_DbSelectBracesSniff extends Drupal_Sni /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DefaultValueSanitizeSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DefaultValueSanitizeSniff.php index 921df6402d4a9529e87884915a403dd03383e13e..227c1860907cb16f81f7cbf55e80fdbfa1e7947d 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DefaultValueSanitizeSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/DefaultValueSanitizeSniff.php @@ -1,12 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_FunctionCalls_DefaultValueSanitizeSniff + * \DrupalPractice\Sniffs\FunctionCalls\DefaultValueSanitizeSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; +use PHP_CodeSniffer\Util\Tokens; + /** * Check that sanitization functions such as check_plain() are not used on Form * API #default_value elements. @@ -15,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionCalls_DefaultValueSanitizeSniff extends Drupal_Sniffs_Semantics_FunctionCall +class DefaultValueSanitizeSniff extends FunctionCall { @@ -40,18 +46,18 @@ class DrupalPractice_Sniffs_FunctionCalls_DefaultValueSanitizeSniff extends Drup /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket @@ -60,12 +66,12 @@ class DrupalPractice_Sniffs_FunctionCalls_DefaultValueSanitizeSniff extends Drup // We assume that the sequence '#default_value' => check_plain(...) is // wrong because the Form API already sanitizes #default_value. - $arrow = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + $arrow = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($arrow === false || $tokens[$arrow]['code'] !== T_DOUBLE_ARROW) { return; } - $arrayKey = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($arrow - 1), null, true); + $arrayKey = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($arrow - 1), null, true); if ($arrayKey === false || $tokens[$arrayKey]['code'] !== T_CONSTANT_ENCAPSED_STRING || substr($tokens[$arrayKey]['content'], 1, -1) !== '#default_value' diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/FormErrorTSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/FormErrorTSniff.php index 5ad2830d1532093a73a87a4ef7a4866cbb4c27b0..b0bacc3b1e9648d16ac4fd4c509f6b1d1b47e55a 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/FormErrorTSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/FormErrorTSniff.php @@ -1,12 +1,17 @@ <?php /** - * DrupalPractice_Sniffs_FunctionCalls_FormErrorTSniff + * \DrupalPractice\Sniffs\FunctionCalls\FormErrorTSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; + /** * Verifiies that messages passed to form_set_error() run through t(). * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionCalls_FormErrorTSniff extends Drupal_Sniffs_Semantics_FunctionCall +class FormErrorTSniff extends FunctionCall { @@ -36,18 +41,18 @@ class DrupalPractice_Sniffs_FunctionCalls_FormErrorTSniff extends Drupal_Sniffs_ /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/LCheckPlainSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/LCheckPlainSniff.php index 397a150b019d3b0f1347baa023f968092798e584..815fc436cc6ed095034defae877fc57955ba6011 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/LCheckPlainSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/LCheckPlainSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_FunctionCalls_LCheckPlainSniff + * \DrupalPractice\Sniffs\FunctionCalls\Drupal_Sniffs_FunctionCalls_LCheckPlainSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; + /** * The first argument of the l() function should not be check_plain()'ed. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionCalls_LCheckPlainSniff extends Drupal_Sniffs_Semantics_FunctionCall +class LCheckPlainSniff extends FunctionCall { @@ -33,18 +38,18 @@ class DrupalPractice_Sniffs_FunctionCalls_LCheckPlainSniff extends Drupal_Sniffs /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/MessageTSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/MessageTSniff.php index 300eded00bdf96ef134b36dccd415ccb61922707..bf4ac9e6b27b9694b12f8768c0f40fdb7d3698a0 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/MessageTSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/MessageTSniff.php @@ -1,12 +1,17 @@ <?php /** - * DrupalPractice_Sniffs_FunctionCalls_MessageTSniff + * \DrupalPractice\Sniffs\FunctionCalls\MessageTSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; + /** * Verifies that messages passed to drupal_set_message() run through t(). * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionCalls_MessageTSniff extends Drupal_Sniffs_Semantics_FunctionCall +class MessageTSniff extends FunctionCall { @@ -33,18 +38,18 @@ class DrupalPractice_Sniffs_FunctionCalls_MessageTSniff extends Drupal_Sniffs_Se /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/TCheckPlainSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/TCheckPlainSniff.php index 30831c4f3cb70aa48a9744ad6771dc9ee297bd65..8e7e37bbf187ad840324e0d7a33262139438a9b1 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/TCheckPlainSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/TCheckPlainSniff.php @@ -1,12 +1,17 @@ <?php /** - * Drupal_Sniffs_Semantics_FunctionTSniff + * \DrupalPractice\Sniffs\FunctionCalls\TCheckPlainSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; + /** * Check that "@" and "%" placeholders in t()/watchdog() are not escaped twice * with check_plain(). @@ -15,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionCalls_TCheckPlainSniff extends Drupal_Sniffs_Semantics_FunctionCall +class TCheckPlainSniff extends FunctionCall { @@ -37,18 +42,18 @@ class DrupalPractice_Sniffs_FunctionCalls_TCheckPlainSniff extends Drupal_Sniffs /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php index deea2e13a25bb6aa7c39c95b2e8c97501e999b41..1339c4ab368d3a66ddd45a5f7158df4c8fd6867e 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php @@ -1,20 +1,25 @@ <?php /** - * DrupalPractice_Sniffs_FunctionCalls_ThemeSniff + * ThemeSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; + /** - * Checks that theme functions are not directly called. + * \DrupalPractice\Sniffs\FunctionCalls\Checks that theme functions are not directly called. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionCalls_ThemeSniff extends Drupal_Sniffs_Semantics_FunctionCall +class ThemeSniff extends FunctionCall { /** @@ -35,13 +40,13 @@ class DrupalPractice_Sniffs_FunctionCalls_ThemeSniff extends Drupal_Sniffs_Seman /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $functionName = $tokens[$stackPtr]['content']; diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/VariableSetSanitizeSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/VariableSetSanitizeSniff.php index e1723146c740e9c2b56aaad1a0e2b84b015625e1..60937a23e486a2f3982b162c43cba01932d81a62 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/VariableSetSanitizeSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/VariableSetSanitizeSniff.php @@ -1,12 +1,17 @@ <?php /** - * DrupalPractice_Sniffs_FunctionCalls_VariableSetSanitizeSniff + * \DrupalPractice\Sniffs\FunctionCalls\VariableSetSanitizeSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; + /** * Check that variable_set() calls do not run check_plain() or other * sanitization functions on the value. @@ -15,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionCalls_VariableSetSanitizeSniff extends Drupal_Sniffs_Semantics_FunctionCall +class VariableSetSanitizeSniff extends FunctionCall { @@ -34,18 +39,18 @@ class DrupalPractice_Sniffs_FunctionCalls_VariableSetSanitizeSniff extends Drupa /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/AccessHookMenuSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/AccessHookMenuSniff.php index d75975fa5dcb20f15cc74ef4a8fbfddbd18828a8..c4cedb29adc1991a501cae1244968dbc1538596d 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/AccessHookMenuSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/AccessHookMenuSniff.php @@ -1,12 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_FunctionDefinitions_AccessHookMenuSniff. + * \DrupalPractice\Sniffs\FunctionDefinitions\AccessHookMenuSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionDefinitions; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionDefinition; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks that there are no undocumented open access callbacks in hook_menu(). * @@ -14,22 +20,22 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionDefinitions_AccessHookMenuSniff extends Drupal_Sniffs_Semantics_FunctionDefinition +class AccessHookMenuSniff extends FunctionDefinition { /** * Process this function definition. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function name - * in the stack. - * @param int $functionPtr The position of the function keyword - * in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function name + * in the stack. + * @param int $functionPtr The position of the function keyword + * in the stack. * * @return void */ - public function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr) + public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) { $fileExtension = strtolower(substr($phpcsFile->getFilename(), -6)); // Only check in *.module files. @@ -52,7 +58,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_AccessHookMenuSniff extends Drup while ($string !== false) { if (substr($tokens[$string]['content'], 1, -1) === 'access callback') { $array_operator = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($string + 1), null, true @@ -61,7 +67,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_AccessHookMenuSniff extends Drup && $tokens[$array_operator]['code'] === T_DOUBLE_ARROW ) { $callback = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($array_operator + 1), null, true @@ -75,7 +81,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_AccessHookMenuSniff extends Drup $tokens[$functionPtr]['scope_opener'], true ); - if ($commentBefore !== false && in_array($tokens[$commentBefore]['code'], PHP_CodeSniffer_Tokens::$commentTokens) === false) { + if ($commentBefore !== false && in_array($tokens[$commentBefore]['code'], Tokens::$commentTokens) === false) { $warning = 'Open page callback found, please add a comment before the line why there is no access restriction'; $phpcsFile->addWarning($warning, $callback, 'OpenCallback'); } diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/FormAlterDocSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/FormAlterDocSniff.php index 7e518851980d4958337c74105abb56c947359012..746c57d5a77f5f9f5933ee7a83d3450d496c191f 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/FormAlterDocSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/FormAlterDocSniff.php @@ -1,12 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_FunctionDefinitions_FormAlterDocSniff. + * \DrupalPractice\Sniffs\FunctionDefinitions\FormAlterDocSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionDefinitions; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionDefinition; +use DrupalPractice\Project; + /** * Checks that the comment "Implements hook_form_alter()." actually matches the * function signature. @@ -15,22 +21,22 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionDefinitions_FormAlterDocSniff extends Drupal_Sniffs_Semantics_FunctionDefinition +class FormAlterDocSniff extends FunctionDefinition { /** * Process this function definition. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function name - * in the stack. - * @param int $functionPtr The position of the function keyword - * in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function name + * in the stack. + * @param int $functionPtr The position of the function keyword + * in the stack. * * @return void */ - public function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr) + public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) { $tokens = $phpcsFile->getTokens(); $docCommentEnd = $phpcsFile->findPrevious(T_WHITESPACE, ($functionPtr - 1), null, true); @@ -55,7 +61,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_FormAlterDocSniff extends Drupal return; } - $projectName = DrupalPractice_Project::getName($phpcsFile); + $projectName = Project::getName($phpcsFile); if ($projectName === false) { return; } diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/HookInitCssSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/HookInitCssSniff.php index f983713aba4007ce6b14e84c0d481558868affc3..51347fb81c1f10d8120fe4bb52307d0dd9612d5b 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/HookInitCssSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/HookInitCssSniff.php @@ -1,12 +1,19 @@ <?php /** - * DrupalPractice_Sniffs_FunctionDefinitions_HookInitCssSniff. + * \DrupalPractice\Sniffs\FunctionDefinitions\HookInitCssSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionDefinitions; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionDefinition; +use DrupalPractice\Project; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks that drupal_add_css() is not used in hook_init(). * @@ -14,22 +21,22 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionDefinitions_HookInitCssSniff extends Drupal_Sniffs_Semantics_FunctionDefinition +class HookInitCssSniff extends FunctionDefinition { /** * Process this function definition. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function name in the stack. - * name in the stack. - * @param int $functionPtr The position of the function keyword in the stack. - * keyword in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function name + * in the stack. + * @param int $functionPtr The position of the function keyword + * in the stack. * * @return void */ - public function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr) + public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) { $fileExtension = strtolower(substr($phpcsFile->getFilename(), -6)); // Only check in *.module files. @@ -38,7 +45,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_HookInitCssSniff extends Drupal_ } // This check only applies to Drupal 7, not Drupal 6. - if (DrupalPractice_Project::getCoreVersion($phpcsFile) !== '7.x') { + if (Project::getCoreVersion($phpcsFile) !== '7.x') { return; } @@ -57,7 +64,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_HookInitCssSniff extends Drupal_ while ($string !== false) { if ($tokens[$string]['content'] === 'drupal_add_css' || $tokens[$string]['content'] === 'drupal_add_js') { $opener = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($string + 1), null, true diff --git a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/InstallTSniff.php b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/InstallTSniff.php index 94bcaf6179f66c926b913c5f0a6d63fba3a7f715..603a9d0bf8c654454f05d184c755c3da2af3b0a0 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/InstallTSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/FunctionDefinitions/InstallTSniff.php @@ -1,12 +1,19 @@ <?php /** - * DrupalPractice_Sniffs_FunctionCalls_InstallTSniff. + * \DrupalPractice\Sniffs\FunctionDefinitions\InstallTSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\FunctionDefinitions; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionDefinition; +use DrupalPractice\Project; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks that t() and st() are not used in hook_install() and hook_requirements(). * @@ -14,22 +21,22 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_FunctionDefinitions_InstallTSniff extends Drupal_Sniffs_Semantics_FunctionDefinition +class InstallTSniff extends FunctionDefinition { /** * Process this function definition. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function name in the stack. - * name in the stack. - * @param int $functionPtr The position of the function keyword in the stack. - * keyword in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function name + * in the stack. + * @param int $functionPtr The position of the function keyword + * in the stack. * * @return void */ - public function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr) + public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) { $fileExtension = strtolower(substr($phpcsFile->getFilename(), -7)); // Only check in *.install files. @@ -46,7 +53,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_InstallTSniff extends Drupal_Sni } // This check only applies to Drupal 7, not Drupal 8. - if (DrupalPractice_Project::getCoreVersion($phpcsFile) !== '7.x') { + if (Project::getCoreVersion($phpcsFile) !== '7.x') { return; } @@ -59,7 +66,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_InstallTSniff extends Drupal_Sni while ($string !== false) { if ($tokens[$string]['content'] === 't' || $tokens[$string]['content'] === 'st') { $opener = $phpcsFile->findNext( - PHP_CodeSniffer_Tokens::$emptyTokens, + Tokens::$emptyTokens, ($string + 1), null, true diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/AccessAdminPagesSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/AccessAdminPagesSniff.php index d279304e85adc6f6f9e77cee3c115cbcd962af9b..c2629d5cb7a167cee18f349dbf9fbd799a0b4923 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/AccessAdminPagesSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/AccessAdminPagesSniff.php @@ -1,12 +1,17 @@ <?php /** - * DrupalPractice_Sniffs_General_AccessAdminPagesSniff + * \DrupalPractice\Sniffs\General\AccessAdminPagesSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\General; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionDefinition; + /** * Throws a warning if the "access administration pages" string is found in * hook_menu(). @@ -15,22 +20,22 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_General_AccessAdminPagesSniff extends Drupal_Sniffs_Semantics_FunctionDefinition +class AccessAdminPagesSniff extends FunctionDefinition { /** * Process this function definition. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function name in the stack. - * name in the stack. - * @param int $functionPtr The position of the function keyword in the stack. - * keyword in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function + * name in the stack. + * @param int $functionPtr The position of the function + * keyword in the stack. * * @return void */ - public function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr) + public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) { $fileExtension = strtolower(substr($phpcsFile->getFilename(), -6)); // Only check in *.module files. diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/ClassNameSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/ClassNameSniff.php index b2ea15551275f903cbc9bda21c1a7b2d157e55c0..51b45c80695bda770138b708f8553acdb7c4162a 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/ClassNameSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/ClassNameSniff.php @@ -1,12 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_General_ClassNameSniff + * \DrupalPractice\Sniffs\General\ClassNameSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\General; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use DrupalPractice\Project; + /** * Checks that classes without namespaces are properly prefixed with the module * name. @@ -15,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_General_ClassNameSniff implements PHP_CodeSniffer_Sniff +class ClassNameSniff implements Sniff { @@ -37,13 +43,13 @@ class DrupalPractice_Sniffs_General_ClassNameSniff implements PHP_CodeSniffer_Sn /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function + * name in the stack. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { // If there is a PHP 5.3 namespace declaration in the file we return // immediately as classes can be named arbitrary within a namespace. @@ -52,7 +58,7 @@ class DrupalPractice_Sniffs_General_ClassNameSniff implements PHP_CodeSniffer_Sn return; } - $moduleName = DrupalPractice_Project::getName($phpcsFile); + $moduleName = Project::getName($phpcsFile); if ($moduleName === false) { return; } diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/DescriptionTSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/DescriptionTSniff.php index 79244a9b2eb0bccfa7e76f5f3d098a83aba894d2..3ba9d105675982320a2973c2d4b6ca5693eef276 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/DescriptionTSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/DescriptionTSniff.php @@ -1,12 +1,17 @@ <?php /** - * DrupalPractice_Sniffs_General_DescriptionTSniff + * \DrupalPractice\Sniffs\General\DescriptionTSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\General; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that string values for #description in render arrays are translated. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_General_DescriptionTSniff implements PHP_CodeSniffer_Sniff +class DescriptionTSniff implements Sniff { @@ -33,13 +38,13 @@ class DrupalPractice_Sniffs_General_DescriptionTSniff implements PHP_CodeSniffer /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function + * name in the stack. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { // Look for the string "#description". $tokens = $phpcsFile->getTokens(); @@ -64,7 +69,7 @@ class DrupalPractice_Sniffs_General_DescriptionTSniff implements PHP_CodeSniffer if (strlen($content) > 5) { $warning = '#description values usually have to run through t() for translation'; - $phpcsFile->addWarning($warning, $stringToken); + $phpcsFile->addWarning($warning, $stringToken, 'DescriptionT'); } }//end process() diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php index 97648a6692bb8ba7c09e5feb9693997d3151b8e5..86fdec86a30ba42061ac2a57ace4b1f0fe2816c6 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php @@ -1,12 +1,17 @@ <?php /** - * DrupalPractice_Sniffs_General_FormStateInputSniff. + * \DrupalPractice\Sniffs\General\FormStateInputSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\General; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Throws a message whenever $form_state['input'] is used. $form_state['values'] * is preferred. @@ -15,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_General_FormStateInputSniff implements PHP_CodeSniffer_Sniff +class FormStateInputSniff implements Sniff { @@ -34,13 +39,13 @@ class DrupalPractice_Sniffs_General_FormStateInputSniff implements PHP_CodeSniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function + * name in the stack. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { if ($phpcsFile->getTokensAsString($stackPtr, 4) === '$form_state[\'input\']' || $phpcsFile->getTokensAsString($stackPtr, 4) === '$form_state["input"]' diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/LanguageNoneSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/LanguageNoneSniff.php index bb10afa5d54d545ed8f5ae2dcbcfe27547f3c264..642742a9fefb2411fc4698c97dbf33e4623add40 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/LanguageNoneSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/LanguageNoneSniff.php @@ -1,12 +1,17 @@ <?php /** - * DrupalPractice_Sniffs_General_LanguageNoneSniff + * \DrupalPractice\Sniffs\General\LanguageNoneSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\General; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that ['und'] is not used, should be LANGUAGE_NONE. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_General_LanguageNoneSniff implements PHP_CodeSniffer_Sniff +class LanguageNoneSniff implements Sniff { @@ -36,13 +41,13 @@ class DrupalPractice_Sniffs_General_LanguageNoneSniff implements PHP_CodeSniffer /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function + * name in the stack. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $sequence = $phpcsFile->getTokensAsString($stackPtr, 3); if ($sequence === "['und']" || $sequence === '["und"]') { diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/OptionsTSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/OptionsTSniff.php index fced8fc29f6220634cc9b13ab083ead68ec3bffc..74b4d3c8bd6aebabadca80d005f8c7b8a4ff0bac 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/OptionsTSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/OptionsTSniff.php @@ -1,12 +1,17 @@ <?php /** - * DrupalPractice_Sniffs_General_OptionsTSniff + * \DrupalPractice\Sniffs\General\OptionsTSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\General; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that values in #otions form arrays are translated. * @@ -14,7 +19,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_General_OptionsTSniff implements PHP_CodeSniffer_Sniff +class OptionsTSniff implements Sniff { @@ -33,13 +38,13 @@ class DrupalPractice_Sniffs_General_OptionsTSniff implements PHP_CodeSniffer_Sni /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function + * name in the stack. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { // Look for the string "#options". $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/DrupalPractice/Sniffs/General/VariableNameSniff.php b/coder_sniffer/DrupalPractice/Sniffs/General/VariableNameSniff.php index 16285d850001ae55c4067a0229f47127ab69cb30..b8b38e36188491488f0821558f185fbd94593500 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/General/VariableNameSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/General/VariableNameSniff.php @@ -1,12 +1,19 @@ <?php /** - * DrupalPractice_Sniffs_General_VariableNameSniff + * \DrupalPractice\Sniffs\General\VariableNameSniff * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\General; + +use PHP_CodeSniffer\Files\File; +use Drupal\Sniffs\Semantics\FunctionCall; +use DrupalPractice\Project; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks the usage of variable_get() in forms and the variable name. * @@ -14,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_General_VariableNameSniff extends Drupal_Sniffs_Semantics_FunctionCall +class VariableNameSniff extends FunctionCall { @@ -33,18 +40,18 @@ class DrupalPractice_Sniffs_General_VariableNameSniff extends Drupal_Sniffs_Sema /** * Processes this function call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call in - * the stack. - * @param int $openBracket The position of the opening - * parenthesis in the stack. - * @param int $closeBracket The position of the closing - * parenthesis in the stack. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call in + * the stack. + * @param int $openBracket The position of the opening + * parenthesis in the stack. + * @param int $closeBracket The position of the closing + * parenthesis in the stack. * * @return void */ public function processFunctionCall( - PHP_CodeSniffer_File $phpcsFile, + File $phpcsFile, $stackPtr, $openBracket, $closeBracket @@ -53,12 +60,12 @@ class DrupalPractice_Sniffs_General_VariableNameSniff extends Drupal_Sniffs_Sema // We assume that the sequence '#default_value' => variable_get(...) // indicates a variable that the module owns. - $arrow = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + $arrow = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); if ($arrow === false || $tokens[$arrow]['code'] !== T_DOUBLE_ARROW) { return; } - $arrayKey = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($arrow - 1), null, true); + $arrayKey = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($arrow - 1), null, true); if ($arrayKey === false || $tokens[$arrayKey]['code'] !== T_CONSTANT_ENCAPSED_STRING || substr($tokens[$arrayKey]['content'], 1, -1) !== '#default_value' @@ -73,7 +80,7 @@ class DrupalPractice_Sniffs_General_VariableNameSniff extends Drupal_Sniffs_Sema return; } - $moduleName = DrupalPractice_Project::getName($phpcsFile); + $moduleName = Project::getName($phpcsFile); if ($moduleName === false) { return; } diff --git a/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/NamespacedDependencySniff.php b/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/NamespacedDependencySniff.php index 27c827abcde771a3ca99991922c42c73c291524b..d571017bf5e81edafeb02265dd42ace517838bde 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/NamespacedDependencySniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/InfoFiles/NamespacedDependencySniff.php @@ -1,13 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_InfoFiles_NamespacedDependencySniff. + * \DrupalPractice\Sniffs\InfoFiles\NamespacedDependencySniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\InfoFiles; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that all declared dependencies are namespaced. * @@ -15,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_InfoFiles_NamespacedDependencySniff implements PHP_CodeSniffer_Sniff +class NamespacedDependencySniff implements Sniff { @@ -34,13 +39,13 @@ class DrupalPractice_Sniffs_InfoFiles_NamespacedDependencySniff implements PHP_C /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The current file being processed. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return int */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalClassSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalClassSniff.php index 8e62fcc5ccb858571533ab5d50deec2935b45ff1..e93542a50792f252a00aaacc7ff75aaa53063d92 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalClassSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalClassSniff.php @@ -1,12 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_Objects_GlobalClassSniff. + * \DrupalPractice\Sniffs\Objects\GlobalClassSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\Objects; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use DrupalPractice\Project; + /** * Checks that Node::load() calls and friends are not used in forms, controllers or * services. @@ -15,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_Objects_GlobalClassSniff implements PHP_CodeSniffer_Sniff +class GlobalClassSniff implements Sniff { /** @@ -48,13 +54,13 @@ class DrupalPractice_Sniffs_Objects_GlobalClassSniff implements PHP_CodeSniffer_ /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -85,8 +91,8 @@ class DrupalPractice_Sniffs_Objects_GlobalClassSniff implements PHP_CodeSniffer_ $extendsName = $phpcsFile->findExtendedClassName($classPtr); if (($extendsName === false - || in_array($extendsName, DrupalPractice_Sniffs_Objects_GlobalDrupalSniff::$baseClasses) === false) - && DrupalPractice_Project::isServiceClass($phpcsFile, $classPtr) === false + || in_array($extendsName, GlobalDrupalSniff::$baseClasses) === false) + && Project::isServiceClass($phpcsFile, $classPtr) === false ) { return; } diff --git a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalDrupalSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalDrupalSniff.php index 1bf4faf0d7c30cebda3f30955db04dd45da644d1..ee2eda4b293092f0f8af57d0092dbccf8bb67f80 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalDrupalSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalDrupalSniff.php @@ -1,12 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_Objects_GlobalDrupalSniff. + * \DrupalPractice\Sniffs\Objects\GlobalDrupalSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\Objects; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use DrupalPractice\Project; + /** * Checks that \Drupal::service() and friends is not used in forms, controllers, services. * @@ -14,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_Objects_GlobalDrupalSniff implements PHP_CodeSniffer_Sniff +class GlobalDrupalSniff implements Sniff { /** @@ -53,13 +59,13 @@ class DrupalPractice_Sniffs_Objects_GlobalDrupalSniff implements PHP_CodeSniffer /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -89,7 +95,7 @@ class DrupalPractice_Sniffs_Objects_GlobalDrupalSniff implements PHP_CodeSniffer $extendsName = $phpcsFile->findExtendedClassName($classPtr); if (($extendsName === false || in_array($extendsName, static::$baseClasses) === false) - && DrupalPractice_Project::isServiceClass($phpcsFile, $classPtr) === false + && Project::isServiceClass($phpcsFile, $classPtr) === false ) { return; } diff --git a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalFunctionSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalFunctionSniff.php index 29d7f790205207a76d49b56013795b79bcf5a10e..969d1c808ad1dab7af42d99cb4e60340409ce821 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalFunctionSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Objects/GlobalFunctionSniff.php @@ -1,12 +1,19 @@ <?php /** - * DrupalPractice_Sniffs_Objects_GlobalFunctionSniff. + * \DrupalPractice\Sniffs\Objects\GlobalFunctionSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\Objects; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; +use DrupalPractice\Sniffs\Objects\GlobalDrupalSniff; +use DrupalPractice\Project; + /** * Checks that global functions like t() are not used in forms or controllers. * @@ -14,7 +21,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_Objects_GlobalFunctionSniff implements PHP_CodeSniffer_Sniff +class GlobalFunctionSniff implements Sniff { /** @@ -54,13 +61,13 @@ class DrupalPractice_Sniffs_Objects_GlobalFunctionSniff implements PHP_CodeSniff /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -94,8 +101,8 @@ class DrupalPractice_Sniffs_Objects_GlobalFunctionSniff implements PHP_CodeSniff $extendsName = $phpcsFile->findExtendedClassName($classPtr); if (($extendsName === false - || in_array($extendsName, DrupalPractice_Sniffs_Objects_GlobalDrupalSniff::$baseClasses) === false) - && DrupalPractice_Project::isServiceClass($phpcsFile, $classPtr) === false + || in_array($extendsName, GlobalDrupalSniff::$baseClasses) === false) + && Project::isServiceClass($phpcsFile, $classPtr) === false ) { return; } diff --git a/coder_sniffer/DrupalPractice/Sniffs/Objects/UnusedPrivateMethodSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Objects/UnusedPrivateMethodSniff.php index 7a55f7ef91ef80a88263dc16d840179cedb31831..63f9e40bd0080a87187d5220ec932517ccfeefef 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Objects/UnusedPrivateMethodSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Objects/UnusedPrivateMethodSniff.php @@ -1,12 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_Objects_UnusedPrivateMethodSniff. + * \DrupalPractice\Sniffs\Objects\UnusedPrivateMethodSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\Objects; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\AbstractScopeSniff; +use PHP_CodeSniffer\Util\Tokens; + /** * Checks that private methods are actually used in a class. * @@ -14,7 +20,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_Objects_UnusedPrivateMethodSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff +class UnusedPrivateMethodSniff extends AbstractScopeSniff { @@ -31,14 +37,14 @@ class DrupalPractice_Sniffs_Objects_UnusedPrivateMethodSniff extends PHP_CodeSni /** * Processes the tokens within the scope. * - * @param PHP_CodeSniffer_File $phpcsFile The file being processed. - * @param int $stackPtr The position where this token was - * found. - * @param int $currScope The position of the current scope. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being processed. + * @param int $stackPtr The position where this token was + * found. + * @param int $currScope The position of the current scope. * * @return void */ - protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope) + protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) { // Only check private methods. $methodProperties = $phpcsFile->getMethodProperties($stackPtr); @@ -60,18 +66,18 @@ class DrupalPractice_Sniffs_Objects_UnusedPrivateMethodSniff extends PHP_CodeSni continue; } - $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($current + 1), null, true); + $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($current + 1), null, true); if ($next === false) { continue; } if ($tokens[$next]['code'] === T_OBJECT_OPERATOR) { - $call = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); + $call = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true); if ($call === false || $tokens[$call]['content'] !== $methodName) { continue; } - $parenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($call + 1), null, true); + $parenthesis = $phpcsFile->findNext(Tokens::$emptyTokens, ($call + 1), null, true); if ($parenthesis === false || $tokens[$parenthesis]['code'] !== T_OPEN_PARENTHESIS) { continue; } @@ -80,7 +86,7 @@ class DrupalPractice_Sniffs_Objects_UnusedPrivateMethodSniff extends PHP_CodeSni // can stop. return; } else if ($tokens[$next]['code'] === T_COMMA) { - $call = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true); + $call = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true); if ($call === false || substr($tokens[$call]['content'], 1, -1) !== $methodName) { continue; } @@ -98,4 +104,19 @@ class DrupalPractice_Sniffs_Objects_UnusedPrivateMethodSniff extends PHP_CodeSni }//end processTokenWithinScope() + /** + * Process tokens outside of scope. + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being processed. + * @param int $stackPtr The position where this token was + * found. + * + * @return void + */ + protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) + { + + }//end processTokenOutsideScope() + + }//end class diff --git a/coder_sniffer/DrupalPractice/Sniffs/Yaml/RoutingAccessSniff.php b/coder_sniffer/DrupalPractice/Sniffs/Yaml/RoutingAccessSniff.php index 7834966730cd22a047e96fec10cefb929454529e..7ca3619545ef61d6eacd02d849efc9afe18d0009 100644 --- a/coder_sniffer/DrupalPractice/Sniffs/Yaml/RoutingAccessSniff.php +++ b/coder_sniffer/DrupalPractice/Sniffs/Yaml/RoutingAccessSniff.php @@ -1,13 +1,18 @@ <?php /** - * DrupalPractice_Sniffs_Yaml_RoutingAccessSniff. + * \DrupalPractice\Sniffs\Yaml\RoutingAccessSniff. * * @category PHP * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ +namespace DrupalPractice\Sniffs\Yaml; + +use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; + /** * Checks that there are no undocumented open access callbacks in *.routing.yml files. * @@ -17,7 +22,7 @@ * @package PHP_CodeSniffer * @link http://pear.php.net/package/PHP_CodeSniffer */ -class DrupalPractice_Sniffs_Yaml_RoutingAccessSniff implements PHP_CodeSniffer_Sniff +class RoutingAccessSniff implements Sniff { @@ -36,13 +41,13 @@ class DrupalPractice_Sniffs_Yaml_RoutingAccessSniff implements PHP_CodeSniffer_S /** * Processes this test, when one of its tokens is encountered. * - * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. + * @param \PHP_CodeSniffer\Files\File $phpcsFile The current file being processed. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. * * @return int */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/coder_sniffer/DrupalPractice/Test/CodeAnalysis/VariableAnalysisUnitTest.php b/coder_sniffer/DrupalPractice/Test/CodeAnalysis/VariableAnalysisUnitTest.php index 59b67326098fb82fbc350c543a30e7979e9612ad..8026e308d28f4838d32b68a76bdb697135c41926 100644 --- a/coder_sniffer/DrupalPractice/Test/CodeAnalysis/VariableAnalysisUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/CodeAnalysis/VariableAnalysisUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace DrupalPractice\Sniffs\CodeAnalysis; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the VariableAnalysis sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisUnitTest extends CoderSniffUnitTest +class VariableAnalysisUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisUnitTest extends CoderS * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisUnitTest extends CoderS * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array( 4 => 1, diff --git a/coder_sniffer/DrupalPractice/Test/Commenting/AuthorTagUnitTest.php b/coder_sniffer/DrupalPractice/Test/Commenting/AuthorTagUnitTest.php index 7864c69d7a09e8d87fe0c690d19df0f23fe298e4..f12e84edf04f8bd94a7b9b40e203e2bc3d4c8a3c 100644 --- a/coder_sniffer/DrupalPractice/Test/Commenting/AuthorTagUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/Commenting/AuthorTagUnitTest.php @@ -1,6 +1,10 @@ <?php -class DrupalPractice_Sniffs_Commenting_AuthorTagUnitTest extends CoderSniffUnitTest +namespace DrupalPractice\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class AuthorTagUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class DrupalPractice_Sniffs_Commenting_AuthorTagUnitTest extends CoderSniffUnitT * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -27,7 +31,7 @@ class DrupalPractice_Sniffs_Commenting_AuthorTagUnitTest extends CoderSniffUnitT * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array( 7 => 1, diff --git a/coder_sniffer/DrupalPractice/Test/Commenting/CommentEmptyLineUnitTest.php b/coder_sniffer/DrupalPractice/Test/Commenting/CommentEmptyLineUnitTest.php index eddda0df22425586003799f4d5ea8251f45b4726..2edc500a909ac0db6ac7496046c91adfb0639614 100644 --- a/coder_sniffer/DrupalPractice/Test/Commenting/CommentEmptyLineUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/Commenting/CommentEmptyLineUnitTest.php @@ -3,13 +3,17 @@ * Unit test class for the CommentEmptyLine sniff. */ +namespace DrupalPractice\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the EmptyStatement sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_Commenting_CommentEmptyLineUnitTest extends CoderSniffUnitTest +class CommentEmptyLineUnitTest extends CoderSniffUnitTest { @@ -21,7 +25,7 @@ class DrupalPractice_Sniffs_Commenting_CommentEmptyLineUnitTest extends CoderSni * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -36,7 +40,7 @@ class DrupalPractice_Sniffs_Commenting_CommentEmptyLineUnitTest extends CoderSni * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array(3 => 1); diff --git a/coder_sniffer/DrupalPractice/Test/Commenting/ExpectedExceptionUnitTest.php b/coder_sniffer/DrupalPractice/Test/Commenting/ExpectedExceptionUnitTest.php index 1100f915bfcc0db1463300c561ca2c0db3f17a1a..6f3e5811f4644a027bb8561540a818b08474688b 100644 --- a/coder_sniffer/DrupalPractice/Test/Commenting/ExpectedExceptionUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/Commenting/ExpectedExceptionUnitTest.php @@ -1,6 +1,10 @@ <?php -class DrupalPractice_Sniffs_Commenting_ExpectedExceptionUnitTest extends CoderSniffUnitTest +namespace DrupalPractice\Sniffs\Commenting; + +use Drupal\Test\CoderSniffUnitTest; + +class ExpectedExceptionUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class DrupalPractice_Sniffs_Commenting_ExpectedExceptionUnitTest extends CoderSn * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -27,7 +31,7 @@ class DrupalPractice_Sniffs_Commenting_ExpectedExceptionUnitTest extends CoderSn * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array( 8 => 1, diff --git a/coder_sniffer/DrupalPractice/Test/Constants/GlobalConstantUnitTest.php b/coder_sniffer/DrupalPractice/Test/Constants/GlobalConstantUnitTest.php index 1b9a5440155d3db3883b377a6f77ac9e397c901a..890eebd82a6e04a87314495fedaff754d70fb754 100644 --- a/coder_sniffer/DrupalPractice/Test/Constants/GlobalConstantUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/Constants/GlobalConstantUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace DrupalPractice\Sniffs\Constants; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the OptionsT sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_Constants_GlobalConstantUnitTest extends CoderSniffUnitTest +class GlobalConstantUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_Sniffs_Constants_GlobalConstantUnitTest extends CoderSniffU * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class DrupalPractice_Sniffs_Constants_GlobalConstantUnitTest extends CoderSniffU * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array( 3 => 1, diff --git a/coder_sniffer/DrupalPractice/Test/Constants/GlobalDefineUnitTest.php b/coder_sniffer/DrupalPractice/Test/Constants/GlobalDefineUnitTest.php index 49f551eca356cb5cc4f4c93db11827198e0cd3fb..f2453985fe5d3b6d7e336bf705d7b7edb61197da 100644 --- a/coder_sniffer/DrupalPractice/Test/Constants/GlobalDefineUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/Constants/GlobalDefineUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace DrupalPractice\Sniffs\Constants; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the OptionsT sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_Constants_GlobalDefineUnitTest extends CoderSniffUnitTest +class GlobalDefineUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_Sniffs_Constants_GlobalDefineUnitTest extends CoderSniffUni * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class DrupalPractice_Sniffs_Constants_GlobalDefineUnitTest extends CoderSniffUni * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array( 3 => 1, diff --git a/coder_sniffer/DrupalPractice/Test/FunctionCalls/CheckPlainUnitTest.php b/coder_sniffer/DrupalPractice/Test/FunctionCalls/CheckPlainUnitTest.php index ee01d2b9dc450aaa4562aea837c8dd2bd971c75d..afe0aa7065b870853cef43cc48f581c22a25f6c6 100644 --- a/coder_sniffer/DrupalPractice/Test/FunctionCalls/CheckPlainUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/FunctionCalls/CheckPlainUnitTest.php @@ -3,13 +3,17 @@ * Unit test class for the CheckPlain sniff. */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the CheckPlain sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_FunctionCalls_CheckPlainUnitTest extends CoderSniffUnitTest +class CheckPlainUnitTest extends CoderSniffUnitTest { @@ -21,7 +25,7 @@ class DrupalPractice_Sniffs_FunctionCalls_CheckPlainUnitTest extends CoderSniffU * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -36,7 +40,7 @@ class DrupalPractice_Sniffs_FunctionCalls_CheckPlainUnitTest extends CoderSniffU * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array(3 => 1); diff --git a/coder_sniffer/DrupalPractice/Test/FunctionCalls/CurlSslVerifierUnitTest.php b/coder_sniffer/DrupalPractice/Test/FunctionCalls/CurlSslVerifierUnitTest.php index b3f628f538583aa13c7aa2d06148da5030cc787d..73e4e53792ceb0e62accd961a82e1303e5e99e04 100644 --- a/coder_sniffer/DrupalPractice/Test/FunctionCalls/CurlSslVerifierUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/FunctionCalls/CurlSslVerifierUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace DrupalPractice\Sniffs\FunctionCalls; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the CurlSslVerifier sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_FunctionCalls_CurlSslVerifierUnitTest extends CoderSniffUnitTest +class CurlSslVerifierUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_Sniffs_FunctionCalls_CurlSslVerifierUnitTest extends CoderS * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class DrupalPractice_Sniffs_FunctionCalls_CurlSslVerifierUnitTest extends CoderS * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array(4 => 1); diff --git a/coder_sniffer/DrupalPractice/Test/FunctionCalls/DbQueryUnitTest.php b/coder_sniffer/DrupalPractice/Test/FunctionCalls/DbQueryUnitTest.php index a6be997de48aa719cc0bf94344529df5b2ad5693..18343b2f11307e3ecc5d184cfca1b4b1d257fe4f 100644 --- a/coder_sniffer/DrupalPractice/Test/FunctionCalls/DbQueryUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/FunctionCalls/DbQueryUnitTest.php @@ -3,13 +3,17 @@ * Unit test class for the DbQuery sniff. */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the DbQuery sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_FunctionCalls_DbQueryUnitTest extends CoderSniffUnitTest +class DbQueryUnitTest extends CoderSniffUnitTest { @@ -21,7 +25,7 @@ class DrupalPractice_Sniffs_FunctionCalls_DbQueryUnitTest extends CoderSniffUnit * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -36,7 +40,7 @@ class DrupalPractice_Sniffs_FunctionCalls_DbQueryUnitTest extends CoderSniffUnit * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array( 3 => 1, diff --git a/coder_sniffer/DrupalPractice/Test/FunctionCalls/DbSelectBracesUnitTest.php b/coder_sniffer/DrupalPractice/Test/FunctionCalls/DbSelectBracesUnitTest.php index 2e88dd7f524e35275ee4ce7a5e9199d3e8ec0d4b..673a5cda7e308a0da047afe4ddc318437adb181b 100644 --- a/coder_sniffer/DrupalPractice/Test/FunctionCalls/DbSelectBracesUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/FunctionCalls/DbSelectBracesUnitTest.php @@ -3,13 +3,17 @@ * Unit test class for the DbSelectBraces sniff. */ +namespace DrupalPractice\Sniffs\FunctionCalls; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the DbSelectBraces sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_FunctionCalls_DbSelectBracesUnitTest extends CoderSniffUnitTest +class DbSelectBracesUnitTest extends CoderSniffUnitTest { @@ -21,7 +25,7 @@ class DrupalPractice_Sniffs_FunctionCalls_DbSelectBracesUnitTest extends CoderSn * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -36,7 +40,7 @@ class DrupalPractice_Sniffs_FunctionCalls_DbSelectBracesUnitTest extends CoderSn * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array(3 => 1); diff --git a/coder_sniffer/DrupalPractice/Test/FunctionCalls/DefaultValueSanitizeUnitTest.php b/coder_sniffer/DrupalPractice/Test/FunctionCalls/DefaultValueSanitizeUnitTest.php index feaca9d5fb5c78ced5ac374f17dd8ebba91d4717..0599a60251dc89445ba274025b6b7d1875f25c48 100644 --- a/coder_sniffer/DrupalPractice/Test/FunctionCalls/DefaultValueSanitizeUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/FunctionCalls/DefaultValueSanitizeUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace DrupalPractice\Sniffs\FunctionCalls; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the DefaultValueSanitize sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_FunctionCalls_DefaultValueSanitizeUnitTest extends CoderSniffUnitTest +class DefaultValueSanitizeUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_Sniffs_FunctionCalls_DefaultValueSanitizeUnitTest extends C * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class DrupalPractice_Sniffs_FunctionCalls_DefaultValueSanitizeUnitTest extends C * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array(6 => 1); diff --git a/coder_sniffer/DrupalPractice/Test/FunctionCalls/TCheckPlainUnitTest.php b/coder_sniffer/DrupalPractice/Test/FunctionCalls/TCheckPlainUnitTest.php index ccbd7d40995c007d2df3748e5ba0f06c0f8775a5..4161264dbd71664a2ca85a290474973286187fb0 100644 --- a/coder_sniffer/DrupalPractice/Test/FunctionCalls/TCheckPlainUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/FunctionCalls/TCheckPlainUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace DrupalPractice\Sniffs\FunctionCalls; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the TCheckPlain sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_FunctionCalls_TCheckPlainUnitTest extends CoderSniffUnitTest +class TCheckPlainUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_Sniffs_FunctionCalls_TCheckPlainUnitTest extends CoderSniff * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class DrupalPractice_Sniffs_FunctionCalls_TCheckPlainUnitTest extends CoderSniff * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array(8 => 1); }//end getWarningList() diff --git a/coder_sniffer/DrupalPractice/Test/FunctionCalls/VariableSetSanitizeUnitTest.php b/coder_sniffer/DrupalPractice/Test/FunctionCalls/VariableSetSanitizeUnitTest.php index 3d0a260d60de80a6549b4c738a2c05aa726b4666..976db05850d9fa92db258fa7f870a45b7604082e 100644 --- a/coder_sniffer/DrupalPractice/Test/FunctionCalls/VariableSetSanitizeUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/FunctionCalls/VariableSetSanitizeUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace DrupalPractice\Sniffs\FunctionCalls; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the VariableSetSanitize sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_FunctionCalls_VariableSetSanitizeUnitTest extends CoderSniffUnitTest +class VariableSetSanitizeUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_Sniffs_FunctionCalls_VariableSetSanitizeUnitTest extends Co * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class DrupalPractice_Sniffs_FunctionCalls_VariableSetSanitizeUnitTest extends Co * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array(3 => 1); diff --git a/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/AccessHookMenuUnitTest.php b/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/AccessHookMenuUnitTest.php index 9ea875b66d4d2a137f1bcfbc8e8bb89394b894e3..30f1447fe8bf4162329b21b4ad208cd213d724dd 100644 --- a/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/AccessHookMenuUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/AccessHookMenuUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace DrupalPractice\Sniffs\FunctionDefinitions; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the HookInitCss sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_FunctionDefinitions_AccessHookMenuUnitTest extends CoderSniffUnitTest +class AccessHookMenuUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_AccessHookMenuUnitTest extends C * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_AccessHookMenuUnitTest extends C * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array( 24 => 1, @@ -46,7 +50,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_AccessHookMenuUnitTest extends C * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return array(__DIR__ . '/test.module'); } diff --git a/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/FormAlterDocUnitTest.php b/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/FormAlterDocUnitTest.php index 0147b5ad006ec603e45740b30d96ef64238d5195..07027cad84931cf3503d32bd62c0962c827f642f 100644 --- a/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/FormAlterDocUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/FormAlterDocUnitTest.php @@ -1,6 +1,10 @@ <?php -class DrupalPractice_Sniffs_FunctionDefinitions_FormAlterDocUnitTest extends CoderSniffUnitTest +namespace DrupalPractice\Sniffs\FunctionDefinitions; + +use Drupal\Test\CoderSniffUnitTest; + +class FormAlterDocUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_FormAlterDocUnitTest extends Cod * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -27,7 +31,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_FormAlterDocUnitTest extends Cod * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array( 31 => 1, @@ -40,7 +44,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_FormAlterDocUnitTest extends Cod * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return array(__DIR__ . '/test.module'); } diff --git a/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/HookInitCssUnitTest.php b/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/HookInitCssUnitTest.php index db9237abd02d5568b28ee7fae64deb9a140e9e12..66e54b7c8bfbb9565e2c4179c381eeed6cf314e4 100644 --- a/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/HookInitCssUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/HookInitCssUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace DrupalPractice\Sniffs\FunctionDefinitions; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the HookInitCss sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_FunctionDefinitions_HookInitCssUnitTest extends CoderSniffUnitTest +class HookInitCssUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_HookInitCssUnitTest extends Code * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_HookInitCssUnitTest extends Code * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array( 7 => 1, @@ -47,7 +51,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_HookInitCssUnitTest extends Code * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return array(__DIR__ . '/test.module'); } diff --git a/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/InstallTSniffUnitTest.php b/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/InstallTSniffUnitTest.php index 2442b894e5674b44c19f6345f5f538a5c8ab3d1c..c14673769367aebe2978464f21634c1e4f31068b 100644 --- a/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/InstallTSniffUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/FunctionDefinitions/InstallTSniffUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace DrupalPractice\Sniffs\FunctionDefinitions; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the InstallT sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_FunctionDefinitions_InstallTUnitTest extends CoderSniffUnitTest +class InstallTUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_InstallTUnitTest extends CoderSn * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array( 12 => 1, @@ -35,7 +39,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_InstallTUnitTest extends CoderSn * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); @@ -46,7 +50,7 @@ class DrupalPractice_Sniffs_FunctionDefinitions_InstallTUnitTest extends CoderSn * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return array(__DIR__ . '/test.install'); } diff --git a/coder_sniffer/DrupalPractice/Test/General/OptionsTUnitTest.php b/coder_sniffer/DrupalPractice/Test/General/OptionsTUnitTest.php index 8af305e93b3667df3514f7a931c33c09e4e738a6..9dd44bf21d5a478a771b281105c7788308f046c0 100644 --- a/coder_sniffer/DrupalPractice/Test/General/OptionsTUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/General/OptionsTUnitTest.php @@ -1,12 +1,16 @@ <?php +namespace DrupalPractice\Sniffs\General; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the OptionsT sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_General_OptionsTUnitTest extends CoderSniffUnitTest +class OptionsTUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_Sniffs_General_OptionsTUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class DrupalPractice_Sniffs_General_OptionsTUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array(14 => 1); diff --git a/coder_sniffer/DrupalPractice/Test/General/VariableNameUnitTest.php b/coder_sniffer/DrupalPractice/Test/General/VariableNameUnitTest.php index 162d97d609ab5f3d7799755a5a0dd6cfe00cc38e..8ee62bd5a0e7a4163716815e25e52601b2dd815d 100644 --- a/coder_sniffer/DrupalPractice/Test/General/VariableNameUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/General/VariableNameUnitTest.php @@ -3,13 +3,17 @@ * Unit test class for the CommentEmptyLine sniff. */ +namespace DrupalPractice\Sniffs\General; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for the VariableName sniff. * * A sniff unit test checks a .inc file for expected violations of a single * coding standard. Expected errors and warnings are stored in this class. */ -class DrupalPractice_Sniffs_General_VariableNameUnitTest extends CoderSniffUnitTest +class VariableNameUnitTest extends CoderSniffUnitTest { @@ -21,7 +25,7 @@ class DrupalPractice_Sniffs_General_VariableNameUnitTest extends CoderSniffUnitT * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -36,7 +40,7 @@ class DrupalPractice_Sniffs_General_VariableNameUnitTest extends CoderSniffUnitT * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array(11 => 1); diff --git a/coder_sniffer/DrupalPractice/Test/InfoFiles/NamespacedDependencyUnitTest.php b/coder_sniffer/DrupalPractice/Test/InfoFiles/NamespacedDependencyUnitTest.php index 52341e87c6f748a3fabac673d08d8f82af089371..8a3ddbe8d923445d65e452e73b59eb8a73efc266 100644 --- a/coder_sniffer/DrupalPractice/Test/InfoFiles/NamespacedDependencyUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/InfoFiles/NamespacedDependencyUnitTest.php @@ -1,6 +1,10 @@ <?php -class DrupalPractice_Sniffs_InfoFiles_NamespacedDependencyUnitTest extends CoderSniffUnitTest +namespace DrupalPractice\Sniffs\InfoFiles; + +use Drupal\Test\CoderSniffUnitTest; + +class NamespacedDependencyUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class DrupalPractice_Sniffs_InfoFiles_NamespacedDependencyUnitTest extends Coder * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -27,7 +31,7 @@ class DrupalPractice_Sniffs_InfoFiles_NamespacedDependencyUnitTest extends Coder * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array( 9 => 1, @@ -42,7 +46,7 @@ class DrupalPractice_Sniffs_InfoFiles_NamespacedDependencyUnitTest extends Coder * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return array(__DIR__ . '/dependencies_test.info.yml'); } diff --git a/coder_sniffer/DrupalPractice/Test/Objects/GlobalClassUnitTest.php b/coder_sniffer/DrupalPractice/Test/Objects/GlobalClassUnitTest.php index 2c83bcc7981bbd9e958b04b4a70bffee118a1c05..3a7d97a8c62382b127717184dccedec813a47f0d 100644 --- a/coder_sniffer/DrupalPractice/Test/Objects/GlobalClassUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/Objects/GlobalClassUnitTest.php @@ -1,6 +1,10 @@ <?php -class DrupalPractice_Sniffs_Objects_GlobalClassUnitTest extends CoderSniffUnitTest +namespace DrupalPractice\Sniffs\Objects; + +use Drupal\Test\CoderSniffUnitTest; + +class GlobalClassUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class DrupalPractice_Sniffs_Objects_GlobalClassUnitTest extends CoderSniffUnitTe * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -27,13 +31,15 @@ class DrupalPractice_Sniffs_Objects_GlobalClassUnitTest extends CoderSniffUnitTe * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { switch ($testFile) { case 'GlobalClassUnitTest.inc': return array(8 => 1); case 'ExampleService.php': return array(23 => 1); + default: + return []; } }//end getWarningList() @@ -43,7 +49,7 @@ class DrupalPractice_Sniffs_Objects_GlobalClassUnitTest extends CoderSniffUnitTe * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return [__DIR__.'/GlobalClassUnitTest.inc', __DIR__.'/src/ExampleService.php']; } diff --git a/coder_sniffer/DrupalPractice/Test/Objects/GlobalDrupalUnitTest.php b/coder_sniffer/DrupalPractice/Test/Objects/GlobalDrupalUnitTest.php index 5350f61c8971e696d02ad93c682ff35da42b14e1..8eb94ee42a7ac652a130a9e23b9c87a047648834 100644 --- a/coder_sniffer/DrupalPractice/Test/Objects/GlobalDrupalUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/Objects/GlobalDrupalUnitTest.php @@ -1,6 +1,10 @@ <?php -class DrupalPractice_Sniffs_Objects_GlobalDrupalUnitTest extends CoderSniffUnitTest +namespace DrupalPractice\Sniffs\Objects; + +use Drupal\Test\CoderSniffUnitTest; + +class GlobalDrupalUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class DrupalPractice_Sniffs_Objects_GlobalDrupalUnitTest extends CoderSniffUnitT * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -27,13 +31,15 @@ class DrupalPractice_Sniffs_Objects_GlobalDrupalUnitTest extends CoderSniffUnitT * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { switch ($testFile) { case 'GlobalDrupalUnitTest.inc': return array(6 => 1); case 'ExampleService.php': return array(16 => 1); + default: + return []; } }//end getWarningList() @@ -44,7 +50,7 @@ class DrupalPractice_Sniffs_Objects_GlobalDrupalUnitTest extends CoderSniffUnitT * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return [__DIR__.'/GlobalDrupalUnitTest.inc', __DIR__.'/src/ExampleService.php']; } diff --git a/coder_sniffer/DrupalPractice/Test/Objects/GlobalFunctionUnitTest.php b/coder_sniffer/DrupalPractice/Test/Objects/GlobalFunctionUnitTest.php index a5857e41520f86ec1d5885e8b8a57666474de809..6d3e6be79402b0b594d69572f1f578fcfeecd9f6 100644 --- a/coder_sniffer/DrupalPractice/Test/Objects/GlobalFunctionUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/Objects/GlobalFunctionUnitTest.php @@ -1,6 +1,10 @@ <?php -class DrupalPractice_Sniffs_Objects_GlobalFunctionUnitTest extends CoderSniffUnitTest +namespace DrupalPractice\Sniffs\Objects; + +use Drupal\Test\CoderSniffUnitTest; + +class GlobalFunctionUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class DrupalPractice_Sniffs_Objects_GlobalFunctionUnitTest extends CoderSniffUni * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -27,13 +31,15 @@ class DrupalPractice_Sniffs_Objects_GlobalFunctionUnitTest extends CoderSniffUni * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { switch ($testFile) { case 'GlobalFunctionUnitTest.inc': return array(6 => 1); case 'ExampleService.php': return array(30 => 1); + default: + return []; } }//end getWarningList() @@ -44,7 +50,7 @@ class DrupalPractice_Sniffs_Objects_GlobalFunctionUnitTest extends CoderSniffUni * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return [__DIR__.'/GlobalFunctionUnitTest.inc', __DIR__.'/src/ExampleService.php']; } diff --git a/coder_sniffer/DrupalPractice/Test/Objects/UnusedPrivateMethodUnitTest.php b/coder_sniffer/DrupalPractice/Test/Objects/UnusedPrivateMethodUnitTest.php index 992a950a39b308ee4192a492d19a5a8fd108f5d8..212ba21c9123f6aa5856b344addbb7b9f467adc5 100644 --- a/coder_sniffer/DrupalPractice/Test/Objects/UnusedPrivateMethodUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/Objects/UnusedPrivateMethodUnitTest.php @@ -1,6 +1,10 @@ <?php -class DrupalPractice_Sniffs_Objects_UnusedPrivateMethodUnitTest extends CoderSniffUnitTest +namespace DrupalPractice\Sniffs\Objects; + +use Drupal\Test\CoderSniffUnitTest; + +class UnusedPrivateMethodUnitTest extends CoderSniffUnitTest { @@ -12,7 +16,7 @@ class DrupalPractice_Sniffs_Objects_UnusedPrivateMethodUnitTest extends CoderSni * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -27,7 +31,7 @@ class DrupalPractice_Sniffs_Objects_UnusedPrivateMethodUnitTest extends CoderSni * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array(8 => 1); diff --git a/coder_sniffer/DrupalPractice/Test/ProjectDetection/ProjectUnitTest.php b/coder_sniffer/DrupalPractice/Test/ProjectDetection/ProjectUnitTest.php deleted file mode 100644 index 31268b86d8c11536bb054f77dcf14b10a1a2972a..0000000000000000000000000000000000000000 --- a/coder_sniffer/DrupalPractice/Test/ProjectDetection/ProjectUnitTest.php +++ /dev/null @@ -1,79 +0,0 @@ -<?php - -/** - * Tests that project and version detection works. - */ -class ProjectUnitTest extends PHPUnit_Framework_TestCase -{ - - /** - * The mocked file object for testing. - * - * @var PHP_CodeSniffer_File|PHPUnit_Framework_MockObject_MockObject - */ - protected $phpcsFile; - - /** - * {@inheritdoc} - */ - public function setUp() - { - parent::setUp(); - $this->phpcsFile = $this->getMockBuilder('PHP_CodeSniffer_File') - ->disableOriginalConstructor() - ->getMock(); - } - - /** - * Tests the extending classes Sniff class. - */ - public function testInfoFileDetection() - { - $this->phpcsFile->expects($this->any()) - ->method('getFilename') - // The file does not exist, but doesn't matter for this test. - ->will($this->returnValue(dirname(__FILE__) . '/modules/drupal6/test.php')); - - $this->assertEquals(DrupalPractice_Project::getInfoFile($this->phpcsFile), dirname(__FILE__) . '/modules/drupal6/testmodule.info'); - } - - /** - * Tests the extending classes Sniff class. - */ - public function testInfoFileNestedDetection() - { - $this->phpcsFile->expects($this->any()) - ->method('getFilename') - // The file does not exist, but doesn't matter for this test. - ->will($this->returnValue(dirname(__FILE__) . '/modules/drupal6/nested/test.php')); - - $this->assertEquals(DrupalPractice_Project::getInfoFile($this->phpcsFile), dirname(__FILE__) . '/modules/drupal6/testmodule.info'); - } - - /** - * Tests the extending classes Sniff class. - * - * @dataProvider coreVersionProvider - */ - public function testCoreVersion($filename, $core_version) - { - $this->phpcsFile->expects($this->any()) - ->method('getFilename') - // The file does not exist, but doesn't matter for this test. - ->will($this->returnValue($filename)); - - $this->assertEquals(DrupalPractice_Project::getCoreVersion($this->phpcsFile), $core_version); - } - - /** - * Data provider for testCoreVersion(). - */ - public function coreVersionProvider() { - return array( - array(dirname(__FILE__) . '/modules/drupal6/nested/test.php', '6.x'), - array(dirname(__FILE__) . '/modules/drupal7/test.php', '7.x'), - array(dirname(__FILE__) . '/modules/drupal8/test.php', '8.x'), - ); - } - -}//end class diff --git a/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal6/nested/test.php b/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal6/nested/test.php deleted file mode 100644 index 31c91e08346115f337d08add4b54e49510b721b0..0000000000000000000000000000000000000000 --- a/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal6/nested/test.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php - -// Empty file for testing purposes. - diff --git a/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal6/testmodule.info b/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal6/testmodule.info deleted file mode 100644 index 1098c3a5324c888b2a127f03399bd6425d41ec69..0000000000000000000000000000000000000000 --- a/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal6/testmodule.info +++ /dev/null @@ -1,4 +0,0 @@ -name = Test module -description = Test -package = Core -core = 6.x diff --git a/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal7/testmodule.info b/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal7/testmodule.info deleted file mode 100644 index fd742e8e72364d67f2173da8c65da3905982405e..0000000000000000000000000000000000000000 --- a/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal7/testmodule.info +++ /dev/null @@ -1,6 +0,0 @@ -name = Test module -description = Test -package = Core -core = 7.x -configure = admin/structure/types -stylesheets[all][] = node.css diff --git a/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal8/testmodule.info.yml b/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal8/testmodule.info.yml deleted file mode 100644 index b7aecc7c66518418d88874d657a6c7a369e38fdd..0000000000000000000000000000000000000000 --- a/coder_sniffer/DrupalPractice/Test/ProjectDetection/modules/drupal8/testmodule.info.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: Test module -type: module -description: 'Test.' -core: 8.x -configure: node.overview_types -dependencies: -- text diff --git a/coder_sniffer/DrupalPractice/Test/Yaml/RoutingAccessUnitTest.php b/coder_sniffer/DrupalPractice/Test/Yaml/RoutingAccessUnitTest.php index 4651bda10d2f726325c97c2889bef1f280b57cd7..39a5983044c12434bb6de0c6af6571306b63d6bb 100644 --- a/coder_sniffer/DrupalPractice/Test/Yaml/RoutingAccessUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/Yaml/RoutingAccessUnitTest.php @@ -1,6 +1,10 @@ <?php -class DrupalPractice_Sniffs_Yaml_RoutingAccessUnitTest extends CoderSniffUnitTest +namespace DrupalPractice\Sniffs\Yaml; + +use Drupal\Test\CoderSniffUnitTest; + +class RoutingAccessUnitTest extends CoderSniffUnitTest { /** @@ -8,7 +12,7 @@ class DrupalPractice_Sniffs_Yaml_RoutingAccessUnitTest extends CoderSniffUnitTes * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { return [__DIR__.'/routing_access_test.routing.yml']; } @@ -21,7 +25,7 @@ class DrupalPractice_Sniffs_Yaml_RoutingAccessUnitTest extends CoderSniffUnitTes * * @return array(int => int) */ - protected function getErrorList($testFile) + protected function getErrorList($testFile = NULL) { return array(); @@ -36,7 +40,7 @@ class DrupalPractice_Sniffs_Yaml_RoutingAccessUnitTest extends CoderSniffUnitTes * * @return array(int => int) */ - protected function getWarningList($testFile) + protected function getWarningList($testFile = NULL) { return array( 7 => 1, diff --git a/coder_sniffer/DrupalPractice/Test/good/GoodUnitTest.php b/coder_sniffer/DrupalPractice/Test/good/GoodUnitTest.php index 9e46ae15832b9609bcc42379f50ed73f709bca75..d03e412c1a95ed4605eb08d7f3771a3195a6d688 100644 --- a/coder_sniffer/DrupalPractice/Test/good/GoodUnitTest.php +++ b/coder_sniffer/DrupalPractice/Test/good/GoodUnitTest.php @@ -3,10 +3,14 @@ * Unit test class for all good files that must not throw errors/warnings. */ +namespace DrupalPractice\good; + +use Drupal\Test\CoderSniffUnitTest; + /** * Unit test class for all good files that must not throw errors/warnings. */ -class DrupalPractice_GoodUnitTest extends CoderSniffUnitTest +class GoodUnitTest extends CoderSniffUnitTest { @@ -18,7 +22,7 @@ class DrupalPractice_GoodUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getErrorList($testFile) + public function getErrorList($testFile = NULL) { return array(); @@ -33,7 +37,7 @@ class DrupalPractice_GoodUnitTest extends CoderSniffUnitTest * * @return array(int => int) */ - public function getWarningList($testFile) + public function getWarningList($testFile = NULL) { return array(); @@ -44,9 +48,9 @@ class DrupalPractice_GoodUnitTest extends CoderSniffUnitTest * * @return array The list of test files. */ - protected function getTestFiles() { + protected function getTestFiles($testFileBase) { $dir = dirname(__FILE__); - $di = new DirectoryIterator($dir); + $di = new \DirectoryIterator($dir); foreach ($di as $file) { $path = $file->getPathname(); @@ -65,9 +69,9 @@ class DrupalPractice_GoodUnitTest extends CoderSniffUnitTest * * @return array The list of sniff codes. */ - protected function getSniffCodes() { + protected function allSniffCodes() { // We want to test all sniffs defined in the standard. - return array(); + return TRUE; } diff --git a/composer.json b/composer.json index 769d890b709a28a771a73ae0df339c0c560d9489..3e4cdbe4176a8d1b6362463563ccffffa5aae236 100644 --- a/composer.json +++ b/composer.json @@ -12,9 +12,15 @@ "require": { "php": ">=5.4.0", "ext-mbstring": "*", - "squizlabs/php_codesniffer": ">=2.8.1 <3.0", + "squizlabs/php_codesniffer": "^3.0.0", "symfony/yaml": ">=2.0.0" }, + "autoload": { + "psr-0": { + "Drupal\\": "coder_sniffer/Drupal/", + "DrupalPractice\\": "coder_sniffer/Drupal/" + } + }, "require-dev": { "phpunit/phpunit": ">=3.7 <6" } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 0ac2eb7243da4565ff9cfb8710ed6814fa0c9c5b..0e340b15a6aab494447019ffcf89deed6829dd63 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -6,7 +6,58 @@ <exclude-pattern>*/Test/*</exclude-pattern> - <rule ref="PHPCS" /> + <!-- The following comes from the 2.9 PHPCS ruleset.xml { --> + + <!-- Include the whole PEAR standard --> + <rule ref="PEAR"/> + + <!-- Include some sniffs from other standards that don't conflict with PEAR --> + <rule ref="Squiz.Arrays.ArrayBracketSpacing" /> + <rule ref="Squiz.Arrays.ArrayDeclaration" /> + <rule ref="Squiz.Commenting.ClosingDeclarationComment" /> + <rule ref="Squiz.ControlStructures.ElseIfDeclaration" /> + <rule ref="Squiz.Commenting.BlockComment" /> + <rule ref="Squiz.Commenting.DocCommentAlignment" /> + <rule ref="Squiz.Commenting.EmptyCatchComment" /> + <rule ref="Squiz.Commenting.InlineComment" /> + <rule ref="Squiz.Commenting.LongConditionClosingComment" /> + <rule ref="Squiz.Commenting.PostStatementComment" /> + <rule ref="Squiz.Formatting.OperatorBracket" /> + <rule ref="Squiz.Operators.ComparisonOperatorUsage" /> + <rule ref="Squiz.PHP.DisallowInlineIf" /> + <rule ref="Squiz.Strings.ConcatenationSpacing" /> + <rule ref="Squiz.WhiteSpace.ControlStructureSpacing" /> + <rule ref="Squiz.WhiteSpace.FunctionClosingBraceSpace" /> + <rule ref="Squiz.WhiteSpace.FunctionSpacing" /> + <rule ref="Squiz.WhiteSpace.OperatorSpacing" /> + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" /> + <rule ref="Generic.Commenting.Todo"/> + <rule ref="Generic.ControlStructures.InlineControlStructure"/> + <rule ref="Generic.Formatting.DisallowMultipleStatements"/> + <rule ref="Generic.Formatting.SpaceAfterCast"/> + <rule ref="Generic.NamingConventions.ConstructorName"/> + <rule ref="Generic.PHP.DeprecatedFunctions"/> + <rule ref="Generic.PHP.LowerCaseKeyword"/> + <rule ref="Generic.Strings.UnnecessaryStringConcat"/> + <rule ref="PSR2.Files.EndFileNewline"/> + <rule ref="Zend.Files.ClosingTag"/> + + <!-- Only one argument per line in multi-line function calls --> + <rule ref="PEAR.Functions.FunctionCallSignature"> + <properties> + <property name="allowMultipleArguments" value="false"/> + </properties> + </rule> + + <!-- Have 12 chars padding maximum and always show as errors --> + <rule ref="Generic.Formatting.MultipleStatementAlignment"> + <properties> + <property name="maxPadding" value="12"/> + <property name="error" value="true"/> + </properties> + </rule> + + <!-- } End of original PHPCS ruleset.xml --> <!-- The following sniffs are disabled because we don't want them --> <rule ref="PEAR.Commenting.FileComment">