aboutsummaryrefslogtreecommitdiffstats
path: root/build/code_sniffer/phpbb/Sniffs
diff options
context:
space:
mode:
Diffstat (limited to 'build/code_sniffer/phpbb/Sniffs')
-rw-r--r--build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php61
-rw-r--r--build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php9
-rw-r--r--build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php9
-rw-r--r--build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php17
4 files changed, 54 insertions, 42 deletions
diff --git a/build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php b/build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php
index 8c0ec853ff..ed8b231be5 100644
--- a/build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php
+++ b/build/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php
@@ -11,6 +11,9 @@
*
*/
+use PHP_CodeSniffer\Files\File;
+use PHP_CodeSniffer\Sniffs\Sniff;
+
/**
* Checks that each PHP source file contains a valid header as defined by the
* phpBB Coding Guidelines.
@@ -18,7 +21,7 @@
* @package code_sniffer
* @author Manuel Pichler <mapi@phpundercontrol.org>
*/
-class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
+class phpbb_Sniffs_Commenting_FileCommentSniff implements Sniff
{
/**
* Returns an array of tokens this test wants to listen for.
@@ -33,13 +36,13 @@ class phpbb_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 File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token
* in the stack passed in $tokens.
*
- * @return null
+ * @return void
*/
- public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ public function process(File $phpcsFile, $stackPtr): void
{
// We are only interested in the first file comment.
if ($stackPtr !== 0)
@@ -62,7 +65,7 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
// Mark as error if this is not a doc comment
else if ($start === false || $tokens[$start]['code'] !== T_DOC_COMMENT_OPEN_TAG)
{
- $phpcsFile->addError('Missing required file doc comment.', $stackPtr);
+ $phpcsFile->addError('Missing required file doc comment.', $stackPtr, 'MissingComment');
return;
}
@@ -82,7 +85,7 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
if ($tokens[$token]['column'] === 1 && (($tokens[$token]['content'] !== '*' && $tokens[$token]['content'] !== ' ') || ($tokens[$token]['content'] === ' ' && $tokens[$token + 1]['content'] !== '*')))
{
$message = 'The file doc comment should not be indented.';
- $phpcsFile->addWarning($message, $token);
+ $phpcsFile->addWarning($message, $token, 'CommentIndented');
}
}
@@ -95,13 +98,13 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
if (!(($tokens[$start + 2]['content'] !== '*' && $tokens[$start + 4]['content'] !== '*') || ($tokens[$start + 3]['content'] !== '*' && $tokens[$start + 6]['content'] !== '*')))
{
$message = 'The first file comment line should be empty.';
- $phpcsFile->addWarning($message, ($start + 1));
+ $phpcsFile->addWarning($message, ($start + 1), 'CommentFirstNotEmpty');
}
if ($tokens[$end - 3]['content'] !== '*' && $tokens[$end - 6]['content'] !== '*')
{
$message = 'The last file comment line should be empty.';
- $phpcsFile->addWarning($message, $end - 1);
+ $phpcsFile->addWarning($message, $end - 1, 'CommentLastNotEmpty');
}
//$this->processPackage($phpcsFile, $start, $tags);
@@ -113,59 +116,59 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
/**
* Checks that the tags array contains a valid package tag
*
- * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param File $phpcsFile The context source file instance.
* @param integer The stack pointer for the first comment token.
* @param array(string=>array) $tags The found file doc comment tags.
*
- * @return null
+ * @return void
*/
- protected function processPackage(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ protected function processPackage(File $phpcsFile, $ptr, $tags): void
{
if (!isset($tags['package']))
{
$message = 'Missing require @package tag in file doc comment.';
- $phpcsFile->addError($message, $ptr);
+ $phpcsFile->addError($message, $ptr, 'MissingTagPackage');
}
else if (preg_match('/^([\w]+)$/', $tags['package'][0]) === 0)
{
$message = 'Invalid content found for @package tag.';
- $phpcsFile->addWarning($message, $tags['package'][1]);
+ $phpcsFile->addWarning($message, $tags['package'][1], 'InvalidTagPackage');
}
}
/**
* Checks that the tags array contains a valid version tag
*
- * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param File $phpcsFile The context source file instance.
* @param integer The stack pointer for the first comment token.
* @param array(string=>array) $tags The found file doc comment tags.
*
- * @return null
+ * @return void
*/
- protected function processVersion(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ protected function processVersion(File $phpcsFile, $ptr, $tags): void
{
if (!isset($tags['version']))
{
$message = 'Missing require @version tag in file doc comment.';
- $phpcsFile->addError($message, $ptr);
+ $phpcsFile->addError($message, $ptr, 'MissingTagVersion');
}
else if (preg_match('/^\$Id:[^\$]+\$$/', $tags['version'][0]) === 0)
{
$message = 'Invalid content found for @version tag, use "$Id: $".';
- $phpcsFile->addError($message, $tags['version'][1]);
+ $phpcsFile->addError($message, $tags['version'][1], 'InvalidTagVersion');
}
}
/**
* Checks that the tags array contains a valid copyright tag
*
- * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param File $phpcsFile The context source file instance.
* @param integer The stack pointer for the first comment token.
* @param array(string=>array) $tags The found file doc comment tags.
*
- * @return null
+ * @return void
*/
- protected function processCopyright(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ protected function processCopyright(File $phpcsFile, $ptr, $tags): void
{
$copyright = '(c) phpBB Limited <https://www.phpbb.com>';
$tokens = $phpcsFile->getTokens();
@@ -177,7 +180,7 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
if ($tokens[$tag + 2]['content'] !== $copyright)
{
$message = 'Invalid content found for the first @copyright tag, use "' . $copyright . '".';
- $phpcsFile->addError($message, $tags['copyright'][0][1]);
+ $phpcsFile->addError($message, $tags['copyright'][0][1], 'InvalidTagCopyright');
}
return;
@@ -185,19 +188,19 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
}
$message = 'Missing require @copyright tag in file doc comment.';
- $phpcsFile->addError($message, $ptr);
+ $phpcsFile->addError($message, $ptr, 'MissingTagCopyright');
}
/**
* Checks that the tags array contains a valid license tag
*
- * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param File $phpcsFile The context source file instance.
* @param integer The stack pointer for the first comment token.
* @param array(string=>array) $tags The found file doc comment tags.
*
- * @return null
+ * @return void
*/
- protected function processLicense(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ protected function processLicense(File $phpcsFile, $ptr, $tags): void
{
$license = 'GNU General Public License, version 2 (GPL-2.0)';
$tokens = $phpcsFile->getTokens();
@@ -210,7 +213,7 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
if ($found)
{
$message = 'It must be only one @license tag in file doc comment.';
- $phpcsFile->addError($message, $ptr);
+ $phpcsFile->addError($message, $ptr, 'MultiTagVersion');
}
$found = true;
@@ -218,7 +221,7 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
if ($tokens[$tag + 2]['content'] !== $license)
{
$message = 'Invalid content found for @license tag, use "' . $license . '".';
- $phpcsFile->addError($message, $tags['license'][0][1]);
+ $phpcsFile->addError($message, $tags['license'][0][1], 'InvalidTagLicense');
}
}
}
@@ -226,7 +229,7 @@ class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
if (!$found)
{
$message = 'Missing require @license tag in file doc comment.';
- $phpcsFile->addError($message, $ptr);
+ $phpcsFile->addError($message, $ptr, 'MissingTagLicense');
}
}
}
diff --git a/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php
index 885c38c5b4..a529fc25cb 100644
--- a/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php
+++ b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php
@@ -11,11 +11,14 @@
*
*/
+use PHP_CodeSniffer\Files\File;
+use PHP_CodeSniffer\Sniffs\Sniff;
+
/**
* Checks that the opening brace of a control structures is on the line after.
* From Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff
*/
-class phpbb_Sniffs_ControlStructures_OpeningBraceBsdAllmanSniff implements PHP_CodeSniffer_Sniff
+class phpbb_Sniffs_ControlStructures_OpeningBraceBsdAllmanSniff implements Sniff
{
/**
* Registers the tokens that this sniff wants to listen for.
@@ -36,13 +39,13 @@ class phpbb_Sniffs_ControlStructures_OpeningBraceBsdAllmanSniff implements PHP_C
/**
* Processes this test, when one of its tokens is encountered.
*
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param 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/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php
index 349bccbb02..d4ecd6cb95 100644
--- a/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php
+++ b/build/code_sniffer/phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php
@@ -11,11 +11,14 @@
*
*/
+use PHP_CodeSniffer\Files\File;
+use PHP_CodeSniffer\Sniffs\Sniff;
+
/**
* Checks that there is exactly one space between the keyword and the opening
* parenthesis of a control structures.
*/
-class phpbb_Sniffs_ControlStructures_OpeningParenthesisSniff implements PHP_CodeSniffer_Sniff
+class phpbb_Sniffs_ControlStructures_OpeningParenthesisSniff implements Sniff
{
/**
* Registers the tokens that this sniff wants to listen for.
@@ -36,13 +39,13 @@ class phpbb_Sniffs_ControlStructures_OpeningParenthesisSniff implements PHP_Code
/**
* Processes this test, when one of its tokens is encountered.
*
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param 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/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
index b3cdbf7496..0279888de1 100644
--- a/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
+++ b/build/code_sniffer/phpbb/Sniffs/Namespaces/UnusedUseSniff.php
@@ -11,10 +11,13 @@
*
*/
+use PHP_CodeSniffer\Files\File;
+use PHP_CodeSniffer\Sniffs\Sniff;
+
/**
* Checks that each use statement is used.
*/
-class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
+class phpbb_Sniffs_Namespaces_UnusedUseSniff implements Sniff
{
/**
* {@inheritdoc}
@@ -24,7 +27,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
return array(T_USE);
}
- protected function check($phpcsFile, $found_name, $full_name, $short_name, $line)
+ protected function check(File $phpcsFile, $found_name, $full_name, $short_name, $line)
{
if ($found_name === $full_name)
@@ -44,7 +47,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
/**
* {@inheritdoc}
*/
- public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ public function process(File $phpcsFile, $stackPtr)
{
if ($this->should_ignore_use($phpcsFile, $stackPtr) === true)
{
@@ -179,13 +182,13 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
/**
* Check if this use statement is part of the namespace block.
*
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in
* the stack passed in $tokens.
*
* @return bool
*/
- private function should_ignore_use(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ private function should_ignore_use(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
@@ -207,7 +210,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
}
/**
- * @param PHP_CodeSniffer_File $phpcsFile
+ * @param File $phpcsFile
* @param int $field
* @param array $tokens
* @param string $class_name_full
@@ -216,7 +219,7 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
*
* @return bool
*/
- private function checkDocblock(PHP_CodeSniffer_File $phpcsFile, $comment_end, $tokens, $class_name_full, $class_name_short)
+ private function checkDocblock(File $phpcsFile, $comment_end, $tokens, $class_name_full, $class_name_short)
{
$ok = false;