jenkins-bot has submitted this change and it was merged.
Change subject: Add function commenting sniff.
......................................................................
Add function commenting sniff.
All new methods should document their parameters and return values as mentioned
in Coding_Conventions.
Details in T136464.
Change-Id: I4918bd59a07490952f5d17242631ab36c350a99e
---
M MediaWiki/Sniffs/AlternativeSyntax/AlternativeSyntaxSniff.php
A MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
M MediaWiki/Sniffs/ControlStructures/AssignmentInControlStructuresSniff.php
M MediaWiki/Sniffs/ControlStructures/IfElseStructureSniff.php
M MediaWiki/Sniffs/ExtraCharacters/CharacterBeforePHPOpeningTagSniff.php
M MediaWiki/Sniffs/NamingConventions/PrefixedGlobalFunctionsSniff.php
M MediaWiki/Sniffs/NamingConventions/ValidGlobalNameSniff.php
M MediaWiki/Sniffs/Usage/DirUsageSniff.php
M MediaWiki/Sniffs/Usage/GotoUsageSniff.php
M MediaWiki/Sniffs/VariableAnalysis/UnusedGlobalVariablesSniff.php
M MediaWiki/Sniffs/WhiteSpace/MultipleEmptyLinesSniff.php
M MediaWiki/Sniffs/WhiteSpace/SpaceAfterControlStructureSniff.php
M MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
M MediaWiki/Sniffs/WhiteSpace/SpaceyParenthesisSniff.php
M MediaWiki/Tests/MediaWikiStandardTest.php
M MediaWiki/Tests/MediaWikiTestHelper.php
A MediaWiki/Tests/files/Commenting/commenting_function_fail.php
A MediaWiki/Tests/files/Commenting/commenting_function_fail.php.expect
A MediaWiki/Tests/files/Commenting/commenting_function_fail.php.fixed
A MediaWiki/Tests/files/Commenting/commenting_function_pass.php
A MediaWiki/Tests/files/Commenting/commenting_function_pass.php.expect
M MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php
M MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php.expect
M MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php.fixed
M MediaWiki/Tests/files/ControlStructures/if_else_structure_pass.php
M
MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php
M
MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php.expect
M
MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php.fixed
M
MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_pass.php
M
MediaWiki/Tests/files/ExtraCharacters/valid_shebang_before_phpopen_tag_fail.php
M
MediaWiki/Tests/files/ExtraCharacters/valid_shebang_before_phpopen_tag_pass.php
M MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php
M MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php.expect
M MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php.fixed
M MediaWiki/Tests/files/NamingConventions/wf_global_function_fail.php
M MediaWiki/Tests/files/NamingConventions/wf_global_function_fail.php.expect
M MediaWiki/Tests/files/NamingConventions/wf_global_function_pass.php
M MediaWiki/Tests/files/NamingConventions/wf_namespace_pass.php
M MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php
M MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php.expect
M MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php.fixed
M MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php
M MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php.expect
M MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php.fixed
M MediaWiki/Tests/files/Usage/dir_usage_pass.php
M MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php
M MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php.expect
M MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php.fixed
M
MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_heredoc_pass.php
M MediaWiki/Tests/files/VariableAnalysis/used_global_variables_pass.php
M
MediaWiki/Tests/files/VariableAnalysis/used_global_variables_quote_string_pass.php
M
MediaWiki/Tests/files/VariableAnalysis/used_global_variables_regression_pass.php
M MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php
M MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php.expect
M MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php.fixed
M MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_pass.php
M MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php
M MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php.expect
M MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php.fixed
M MediaWiki/Tests/files/WhiteSpace/space_before_parens_pass.php
M MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php
M MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php.expect
M MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php.fixed
M MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_pass.php
M MediaWiki/Tests/files/generic_namespace_pass.php
A MediaWiki/Tests/files/generic_namespace_pass.php.fixed
M MediaWiki/Tests/files/generic_pass.php
M TestHelper.php
68 files changed, 826 insertions(+), 75 deletions(-)
Approvals:
EBernhardson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/MediaWiki/Sniffs/AlternativeSyntax/AlternativeSyntaxSniff.php
b/MediaWiki/Sniffs/AlternativeSyntax/AlternativeSyntaxSniff.php
index 7c3d082..b44e4b4 100644
--- a/MediaWiki/Sniffs/AlternativeSyntax/AlternativeSyntaxSniff.php
+++ b/MediaWiki/Sniffs/AlternativeSyntax/AlternativeSyntaxSniff.php
@@ -6,6 +6,10 @@
class MediaWiki_Sniffs_AlternativeSyntax_AlternativeSyntaxSniff
implements PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
+ /**
+ * @return array
+ */
public function register() {
// Per
https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP
// section on alternative syntax.
@@ -19,6 +23,11 @@
];
}
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();
$error = 'Alternative syntax such as "%s" should not be used';
diff --git a/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
new file mode 100644
index 0000000..3c2b473
--- /dev/null
+++ b/MediaWiki/Sniffs/Commenting/FunctionCommentSniff.php
@@ -0,0 +1,333 @@
+<?php
+/**
+ * This file was copied from PHP_CodeSniffer before being modified
+ * File: Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php
+ * From repository: https://github.com/squizlabs/PHP_CodeSniffer
+ *
+ * Parses and verifies the doc comments for functions.
+ *
+ * PHP version 5
+ *
+ * @category PHP
+ * @package PHP_CodeSniffer
+ * @author Greg Sherwood <[email protected]>
+ * @author Marc McIntyre <[email protected]>
+ * @copyright 2006-2014 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
+ */
+// @codingStandardsIgnoreStart
+class MediaWiki_Sniffs_Commenting_FunctionCommentSniff implements
PHP_CodeSniffer_Sniff {
+ // @codingStandardsIgnoreEnd
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register() {
+
+ return [ T_FUNCTION ];
+ }// end register()
+
+ /**
+ * 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
+ */
+ public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
+
+ $tokens = $phpcsFile->getTokens();
+ $find = PHP_CodeSniffer_Tokens::$methodPrefixes;
+ $find[] = T_WHITESPACE;
+ $commentEnd = $phpcsFile->findPrevious( $find, ( $stackPtr - 1
), null, true );
+ if ( $tokens[$commentEnd]['code'] === T_COMMENT ) {
+ // Inline comments might just be closing comments for
+ // control structures or functions instead of function
comments
+ // using the wrong comment type. If there is other code
on the line,
+ // assume they relate to that code.
+ $prev = $phpcsFile->findPrevious( $find, ( $commentEnd
- 1 ), null, true );
+ if ( $prev !== false && $tokens[$prev]['line'] ===
$tokens[$commentEnd]['line'] ) {
+ $commentEnd = $prev;
+ }
+ }
+ if ( $tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
+ && $tokens[$commentEnd]['code'] !== T_COMMENT
+ ) {
+ $phpcsFile->addError( 'Missing function doc comment',
$stackPtr, 'Missing' );
+ $phpcsFile->recordMetric( $stackPtr, 'Function has doc
comment', 'no' );
+ return;
+ } else {
+ $phpcsFile->recordMetric( $stackPtr, 'Function has doc
comment', 'yes' );
+ }
+ if ( $tokens[$commentEnd]['code'] === T_COMMENT ) {
+ $phpcsFile->addError( 'You must use "/**" style
comments for a function comment',
+ $stackPtr, 'WrongStyle' );
+ return;
+ }
+ if ( $tokens[$commentEnd]['line'] !== (
$tokens[$stackPtr]['line'] - 1 ) ) {
+ $error = 'There must be no blank lines after the
function comment';
+ $phpcsFile->addError( $error, $commentEnd,
'SpacingAfter' );
+ }
+ $commentStart = $tokens[$commentEnd]['comment_opener'];
+ foreach ( $tokens[$commentStart]['comment_tags'] as $tag ) {
+ if ( $tokens[$tag]['content'] === '@see' ) {
+ // Make sure the tag isn't empty.
+ $string = $phpcsFile->findNext(
T_DOC_COMMENT_STRING, $tag, $commentEnd );
+ if ( $string === false ||
$tokens[$string]['line'] !== $tokens[$tag]['line'] ) {
+ $error = 'Content missing for @see tag
in function comment';
+ $phpcsFile->addError( $error, $tag,
'EmptySees' );
+ }
+ }
+ }
+ $this->processReturn( $phpcsFile, $stackPtr, $commentStart );
+ $this->processThrows( $phpcsFile, $stackPtr, $commentStart );
+ $this->processParams( $phpcsFile, $stackPtr, $commentStart );
+ }// end process()
+
+ /**
+ * 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.
+ *
+ * @return void
+ */
+ protected function processReturn( PHP_CodeSniffer_File $phpcsFile,
$stackPtr, $commentStart ) {
+
+ $tokens = $phpcsFile->getTokens();
+ // Skip constructor and destructor.
+ $methodName = $phpcsFile->getDeclarationName( $stackPtr );
+ $isSpecialMethod = ( $methodName === '__construct' ||
$methodName === '__destruct' );
+ $return = null;
+ foreach ( $tokens[$commentStart]['comment_tags'] as $tag ) {
+ if ( $tokens[$tag]['content'] === '@return' ) {
+ if ( $return !== null ) {
+ $error = 'Only 1 @return tag is allowed
in a function comment';
+ $phpcsFile->addError( $error, $tag,
'DuplicateReturn' );
+ return;
+ }
+ $return = $tag;
+ }
+ }
+ if ( $isSpecialMethod === true ) {
+ return;
+ }
+ if ( $return !== null ) {
+ $content = $tokens[( $return + 2 )]['content'];
+ if ( empty( $content ) === true || $tokens[( $return +
2 )]['code'] !== T_DOC_COMMENT_STRING ) {
+ $error = 'Return type missing for @return tag
in function comment';
+ $phpcsFile->addError( $error, $return,
'MissingReturnType' );
+ }
+ } else {
+ $error = 'Missing @return tag in function comment';
+ $phpcsFile->addError( $error,
$tokens[$commentStart]['comment_closer'], 'MissingReturn' );
+ }// end if
+ }// end processReturn()
+
+ /**
+ * 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.
+ *
+ * @return void
+ */
+ protected function processThrows( PHP_CodeSniffer_File $phpcsFile,
$stackPtr, $commentStart ) {
+
+ $tokens = $phpcsFile->getTokens();
+ $throws = [];
+ foreach ( $tokens[$commentStart]['comment_tags'] as $tag ) {
+ if ( $tokens[$tag]['content'] !== '@throws' ) {
+ continue;
+ }
+ $exception = null;
+ $comment = null;
+ if ( $tokens[( $tag + 2 )]['code'] ===
T_DOC_COMMENT_STRING ) {
+ $matches = [];
+ preg_match( '/([^\s]+)(?:\s+(.*))?/', $tokens[(
$tag + 2 )]['content'], $matches );
+ $exception = $matches[1];
+ if ( isset( $matches[2] ) === true ) {
+ $comment = $matches[2];
+ }
+ }
+ if ( $exception === null ) {
+ $error = 'Exception type missing for @throws
tag in function comment';
+ $phpcsFile->addError( $error, $tag,
'InvalidThrows' );
+ }
+ }// end foreach
+ }// end processThrows()
+
+ /**
+ * 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.
+ *
+ * @return void
+ */
+ protected function processParams( PHP_CodeSniffer_File $phpcsFile,
$stackPtr, $commentStart ) {
+
+ $tokens = $phpcsFile->getTokens();
+ $params = [];
+ $maxType = 0;
+ $maxVar = 0;
+ foreach ( $tokens[$commentStart]['comment_tags'] as $pos =>
$tag ) {
+ if ( $tokens[$tag]['content'] !== '@param' ) {
+ continue;
+ }
+ $type = '';
+ $typeSpace = 0;
+ $var = '';
+ $varSpace = 0;
+ $comment = '';
+ if ( $tokens[( $tag + 2 )]['code'] ===
T_DOC_COMMENT_STRING ) {
+ $matches = [];
+ preg_match(
'/([^$&.]+)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/',
+ $tokens[( $tag + 2 )]['content'],
$matches );
+ $typeLen = strlen( $matches[1] );
+ $type = trim( $matches[1] );
+ $typeSpace = ( $typeLen - strlen( $type ) );
+ $typeLen = strlen( $type );
+ if ( $typeLen > $maxType ) {
+ $maxType = $typeLen;
+ }
+ if ( isset( $matches[2] ) === true ) {
+ $var = $matches[2];
+ $varLen = strlen( $var );
+ if ( $varLen > $maxVar ) {
+ $maxVar = $varLen;
+ }
+ if ( isset( $matches[4] ) === true ) {
+ $varSpace = strlen( $matches[3]
);
+ $comment = $matches[4];
+ // Any strings until the next
tag belong to this comment.
+ if ( isset(
$tokens[$commentStart]['comment_tags'][( $pos + 1 )] ) === true ) {
+ $end =
$tokens[$commentStart]['comment_tags'][( $pos + 1 )];
+ } else {
+ $end =
$tokens[$commentStart]['comment_closer'];
+ }
+ for ( $i = ( $tag + 3 ); $i <
$end; $i++ ) {
+ if (
$tokens[$i]['code'] === T_DOC_COMMENT_STRING ) {
+ $comment .= '
'.$tokens[$i]['content'];
+ }
+ }
+ } else {
+ $error = 'Missing parameter
comment';
+ $phpcsFile->addError( $error,
$tag, 'MissingParamComment' );
+ }
+ } else {
+ $error = 'Missing parameter name';
+ $phpcsFile->addError( $error, $tag,
'MissingParamName' );
+ }// end if
+ } else {
+ $error = 'Missing parameter type';
+ $phpcsFile->addError( $error, $tag,
'MissingParamType' );
+ }// end if
+ $params[] = [
+ 'tag' => $tag,
+ 'type' => $type,
+ 'var' => $var,
+ 'comment' => $comment,
+ 'type_space' => $typeSpace,
+ 'var_space' => $varSpace,
+ ];
+ }// end foreach
+ $realParams = $phpcsFile->getMethodParameters( $stackPtr );
+ $foundParams = [];
+ // We want to use ... for all variable length arguments, so
added
+ // this prefix to the variable name so comparisons are easier.
+ foreach ( $realParams as $pos => $param ) {
+ if ( $param['variable_length'] === true ) {
+ $realParams[$pos]['name'] =
'...'.$realParams[$pos]['name'];
+ }
+ }
+ foreach ( $params as $pos => $param ) {
+ if ( $param['var'] === '' ) {
+ continue;
+ }
+ $foundParams[] = $param['var'];
+ // Check number of spaces after the type.
+ // $spaces = ( $maxType - strlen( $param['type'] ) + 1
);
+ $spaces = 1;
+ if ( $param['type_space'] !== $spaces ) {
+ $error = 'Expected %s spaces after parameter
type; %s found';
+ $data = [
+ $spaces,
+ $param['type_space'],
+ ];
+ $fix = $phpcsFile->addFixableError( $error,
$param['tag'], 'SpacingAfterParamType', $data );
+ if ( $fix === true ) {
+ $content = $param['type'];
+ $content .= str_repeat( ' ', $spaces );
+ $content .= $param['var'];
+ $content .= str_repeat( ' ',
$param['var_space'] );
+ $content .= $param['comment'];
+ $phpcsFile->fixer->replaceToken( (
$param['tag'] + 2 ), $content );
+ }
+ }
+ // Make sure the param name is correct.
+ if ( isset( $realParams[$pos] ) === true ) {
+ $realName = $realParams[$pos]['name'];
+ if ( $realName !== $param['var'] ) {
+ $code = 'ParamNameNoMatch';
+ $data = [
+ $param['var'],
+ $realName,
+ ];
+ $error = 'Doc comment for parameter %s
does not match ';
+ if ( strtolower( $param['var'] ) ===
strtolower( $realName ) ) {
+ $error .= 'case of ';
+ $code =
'ParamNameNoCaseMatch';
+ }
+ $error .= 'actual variable name %s';
+ $phpcsFile->addError( $error,
$param['tag'], $code, $data );
+ }
+ } elseif ( substr( $param['var'], -4 ) !== ',...' ) {
+ // We must have an extra parameter comment.
+ $error = 'Superfluous parameter comment';
+ $phpcsFile->addError( $error, $param['tag'],
'ExtraParamComment' );
+ }// end if
+ if ( $param['comment'] === '' ) {
+ continue;
+ }
+ // Check number of spaces after the var name.
+ // $spaces = ( $maxVar - strlen( $param['var'] ) + 1 );
+ $spaces = 1;
+ if ( $param['var_space'] !== $spaces &&
+ ltrim( $param['comment'] ) !== '' ) {
+ $error = 'Expected %s spaces after parameter
name; %s found';
+ $data = [
+ $spaces,
+ $param['var_space'],
+ ];
+ $fix = $phpcsFile->addFixableError( $error,
$param['tag'], 'SpacingAfterParamName', $data );
+ if ( $fix === true ) {
+ $content = $param['type'];
+ $content .= str_repeat( ' ',
$param['type_space'] );
+ $content .= $param['var'];
+ $content .= str_repeat( ' ', $spaces );
+ $content .= $param['comment'];
+ $phpcsFile->fixer->replaceToken( (
$param['tag'] + 2 ), $content );
+ }
+ }
+ }// end foreach
+ $realNames = [];
+ foreach ( $realParams as $realParam ) {
+ $realNames[] = $realParam['name'];
+ }
+ // Report missing comments.
+ $diff = array_diff( $realNames, $foundParams );
+ foreach ( $diff as $neededParam ) {
+ $error = 'Doc comment for parameter "%s" missing';
+ $data = [ $neededParam ];
+ $phpcsFile->addError( $error, $commentStart,
'MissingParamTag', $data );
+ }
+ }// end processParams()
+}// end class
diff --git
a/MediaWiki/Sniffs/ControlStructures/AssignmentInControlStructuresSniff.php
b/MediaWiki/Sniffs/ControlStructures/AssignmentInControlStructuresSniff.php
index 4ea1f08..88c0019 100644
--- a/MediaWiki/Sniffs/ControlStructures/AssignmentInControlStructuresSniff.php
+++ b/MediaWiki/Sniffs/ControlStructures/AssignmentInControlStructuresSniff.php
@@ -14,6 +14,10 @@
class MediaWiki_Sniffs_ControlStructures_AssignmentInControlStructuresSniff
implements PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
+ /**
+ * @return array
+ */
public function register() {
return [
T_IF,
@@ -21,6 +25,12 @@
T_ELSEIF,
];
}
+
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
diff --git a/MediaWiki/Sniffs/ControlStructures/IfElseStructureSniff.php
b/MediaWiki/Sniffs/ControlStructures/IfElseStructureSniff.php
index dfc7486..2c0be49 100644
--- a/MediaWiki/Sniffs/ControlStructures/IfElseStructureSniff.php
+++ b/MediaWiki/Sniffs/ControlStructures/IfElseStructureSniff.php
@@ -10,6 +10,10 @@
class MediaWiki_Sniffs_ControlStructures_IfElseStructureSniff
implements PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
+ /**
+ * @return array
+ */
public function register() {
return [
T_ELSE,
@@ -17,6 +21,11 @@
];
}
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();
$prevToken = $tokens[$stackPtr - 1];
diff --git
a/MediaWiki/Sniffs/ExtraCharacters/CharacterBeforePHPOpeningTagSniff.php
b/MediaWiki/Sniffs/ExtraCharacters/CharacterBeforePHPOpeningTagSniff.php
index f00f447..91d606f 100644
--- a/MediaWiki/Sniffs/ExtraCharacters/CharacterBeforePHPOpeningTagSniff.php
+++ b/MediaWiki/Sniffs/ExtraCharacters/CharacterBeforePHPOpeningTagSniff.php
@@ -6,9 +6,19 @@
class MediaWiki_Sniffs_ExtraCharacters_CharacterBeforePHPOpeningTagSniff
implements PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
+ /**
+ * @return array
+ */
public function register() {
return [ T_OPEN_TAG ];
}
+
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
// do nothing if opening tag is the first character
if ( $stackPtr == 0 ) {
diff --git
a/MediaWiki/Sniffs/NamingConventions/PrefixedGlobalFunctionsSniff.php
b/MediaWiki/Sniffs/NamingConventions/PrefixedGlobalFunctionsSniff.php
index aa27121..84b5107 100644
--- a/MediaWiki/Sniffs/NamingConventions/PrefixedGlobalFunctionsSniff.php
+++ b/MediaWiki/Sniffs/NamingConventions/PrefixedGlobalFunctionsSniff.php
@@ -12,6 +12,9 @@
public $ignoreList = [];
+ /**
+ * @return array
+ */
public function register() {
return [ T_FUNCTION ];
@@ -28,8 +31,8 @@
private static $noNamespaceFiles = [];
/**
- * @param PHP_CodeSniffer_File $phpcsFile
- * @param int $ptr
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $ptr The current token index.
*
* @return bool Does a namespace statement exist before this position
in the file?
*/
@@ -72,7 +75,11 @@
return false;
}
-
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
if ( $this->tokenIsNamespaced( $phpcsFile, $stackPtr ) ) {
diff --git a/MediaWiki/Sniffs/NamingConventions/ValidGlobalNameSniff.php
b/MediaWiki/Sniffs/NamingConventions/ValidGlobalNameSniff.php
index 3596e04..ad25cf1 100644
--- a/MediaWiki/Sniffs/NamingConventions/ValidGlobalNameSniff.php
+++ b/MediaWiki/Sniffs/NamingConventions/ValidGlobalNameSniff.php
@@ -6,6 +6,7 @@
// @codingStandardsIgnoreStart
class MediaWiki_Sniffs_NamingConventions_ValidGlobalNameSniff implements
PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
/**
* http://php.net/manual/en/reserved.variables.argv.php
*/
@@ -28,10 +29,18 @@
public $ignoreList = [];
+ /**
+ * @return array
+ */
public function register() {
return [ T_GLOBAL ];
}
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();
diff --git a/MediaWiki/Sniffs/Usage/DirUsageSniff.php
b/MediaWiki/Sniffs/Usage/DirUsageSniff.php
index 43510ca..43c52b6 100644
--- a/MediaWiki/Sniffs/Usage/DirUsageSniff.php
+++ b/MediaWiki/Sniffs/Usage/DirUsageSniff.php
@@ -13,11 +13,20 @@
// @codingStandardsIgnoreStart
class MediaWiki_Sniffs_Usage_DirUsageSniff implements PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
+ /**
+ * @return array
+ */
public function register() {
// As per
https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#Other
return [ T_STRING ];
}
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();
diff --git a/MediaWiki/Sniffs/Usage/GotoUsageSniff.php
b/MediaWiki/Sniffs/Usage/GotoUsageSniff.php
index 7ca1da6..e6975ed 100644
--- a/MediaWiki/Sniffs/Usage/GotoUsageSniff.php
+++ b/MediaWiki/Sniffs/Usage/GotoUsageSniff.php
@@ -5,6 +5,10 @@
// @codingStandardsIgnoreStart
class MediaWiki_Sniffs_Usage_GotoUsageSniff implements PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
+ /**
+ * @return array
+ */
public function register() {
// As per
https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#Other
return [
@@ -12,6 +16,11 @@
];
}
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$error = 'Control statement "goto" must not be used.';
$phpcsFile->addError( $error, $stackPtr, 'GotoUsage' );
diff --git a/MediaWiki/Sniffs/VariableAnalysis/UnusedGlobalVariablesSniff.php
b/MediaWiki/Sniffs/VariableAnalysis/UnusedGlobalVariablesSniff.php
index 566ee54..dc98ed2 100644
--- a/MediaWiki/Sniffs/VariableAnalysis/UnusedGlobalVariablesSniff.php
+++ b/MediaWiki/Sniffs/VariableAnalysis/UnusedGlobalVariablesSniff.php
@@ -7,10 +7,19 @@
class MediaWiki_Sniffs_VariableAnalysis_UnusedGlobalVariablesSniff
implements PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
+ /**
+ * @return array
+ */
public function register() {
return [ T_FUNCTION ];
}
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();
if ( !isset( $tokens[$stackPtr]['scope_opener'] ) ) {
diff --git a/MediaWiki/Sniffs/WhiteSpace/MultipleEmptyLinesSniff.php
b/MediaWiki/Sniffs/WhiteSpace/MultipleEmptyLinesSniff.php
index baae0fa..f81813c 100644
--- a/MediaWiki/Sniffs/WhiteSpace/MultipleEmptyLinesSniff.php
+++ b/MediaWiki/Sniffs/WhiteSpace/MultipleEmptyLinesSniff.php
@@ -6,12 +6,21 @@
class MediaWiki_Sniffs_WhiteSpace_MultipleEmptyLinesSniff
implements PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
+ /**
+ * @return array
+ */
public function register() {
return [
T_WHITESPACE
];
}
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();
diff --git a/MediaWiki/Sniffs/WhiteSpace/SpaceAfterControlStructureSniff.php
b/MediaWiki/Sniffs/WhiteSpace/SpaceAfterControlStructureSniff.php
index d69ae5e..fd299de 100644
--- a/MediaWiki/Sniffs/WhiteSpace/SpaceAfterControlStructureSniff.php
+++ b/MediaWiki/Sniffs/WhiteSpace/SpaceAfterControlStructureSniff.php
@@ -6,6 +6,10 @@
class MediaWiki_Sniffs_WhiteSpace_SpaceAfterControlStructureSniff
implements PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
+ /**
+ * @return array
+ */
public function register() {
// Per
https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#Spaces
return [
@@ -19,6 +23,11 @@
];
}
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();
$nextToken = $tokens[$stackPtr + 1];
diff --git a/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
b/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
index 65d92b7..67accde 100644
--- a/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
+++ b/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
@@ -6,6 +6,7 @@
class MediaWiki_Sniffs_WhiteSpace_SpaceBeforeSingleLineCommentSniff
implements PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
/**
* @return array
*/
@@ -16,8 +17,8 @@
}
/**
- * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
- * @param int $stackPtr The current token index.
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
* @return void
*/
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
diff --git a/MediaWiki/Sniffs/WhiteSpace/SpaceyParenthesisSniff.php
b/MediaWiki/Sniffs/WhiteSpace/SpaceyParenthesisSniff.php
index 7e2ab83..d0ba31c 100644
--- a/MediaWiki/Sniffs/WhiteSpace/SpaceyParenthesisSniff.php
+++ b/MediaWiki/Sniffs/WhiteSpace/SpaceyParenthesisSniff.php
@@ -12,6 +12,10 @@
class MediaWiki_Sniffs_WhiteSpace_SpaceyParenthesisSniff
implements PHP_CodeSniffer_Sniff {
// @codingStandardsIgnoreEnd
+
+ /**
+ * @return array
+ */
public function register() {
return [
T_OPEN_PARENTHESIS,
@@ -21,21 +25,38 @@
];
}
+ /**
+ * @param int $token PHPCS token code.
+ * @return boolean Whether the token code is open.
+ */
private function isOpen( $token ) {
return $token === T_OPEN_PARENTHESIS
|| $token === T_OPEN_SHORT_ARRAY;
}
+ /**
+ * @param int $token PHPCS token code.
+ * @return boolean Whether the token code is closed.
+ */
private function isClosed( $token ) {
return $token === T_CLOSE_PARENTHESIS
|| $token === T_CLOSE_SHORT_ARRAY;
}
+ /**
+ * @param int $token PHPCS token code.
+ * @return boolean Whether the token code is parenthesis.
+ */
private function isParenthesis( $token ) {
return $token === T_OPEN_PARENTHESIS
|| $token === T_CLOSE_PARENTHESIS;
}
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();
@@ -90,14 +111,20 @@
}
if ( $this->isOpen( $currentToken['code'] ) ) {
- $this->processOpenParenthesis( $phpcsFile, $tokens,
$stackPtr );
+ $this->processOpenParenthesis( $phpcsFile, $stackPtr );
} else {
// T_CLOSE_PARENTHESIS
- $this->processCloseParenthesis( $phpcsFile, $tokens,
$stackPtr );
+ $this->processCloseParenthesis( $phpcsFile, $stackPtr );
}
}
- protected function processOpenParenthesis( PHP_CodeSniffer_File
$phpcsFile, $tokens, $stackPtr ) {
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
+ protected function processOpenParenthesis( PHP_CodeSniffer_File
$phpcsFile, $stackPtr ) {
+ $tokens = $phpcsFile->getTokens();
$nextToken = $tokens[$stackPtr + 1];
// No space or not single space
if ( ( $nextToken['code'] === T_WHITESPACE &&
@@ -121,7 +148,13 @@
}
}
- protected function processCloseParenthesis( PHP_CodeSniffer_File
$phpcsFile, $tokens, $stackPtr ) {
+ /**
+ * @param PHP_CodeSniffer_File $phpcsFile PHP_CodeSniffer_File object.
+ * @param int $stackPtr The current token index.
+ * @return void
+ */
+ protected function processCloseParenthesis( PHP_CodeSniffer_File
$phpcsFile, $stackPtr ) {
+ $tokens = $phpcsFile->getTokens();
$previousToken = $tokens[$stackPtr - 1];
if ( $this->isOpen( $previousToken['code'] )
diff --git a/MediaWiki/Tests/MediaWikiStandardTest.php
b/MediaWiki/Tests/MediaWikiStandardTest.php
index 72a94a9..e2b20f7 100644
--- a/MediaWiki/Tests/MediaWikiStandardTest.php
+++ b/MediaWiki/Tests/MediaWikiStandardTest.php
@@ -30,6 +30,9 @@
*/
private $helper;
+ /**
+ * @return void
+ */
public function setUp() {
parent::setUp();
if ( empty( $this->helper ) ) {
@@ -39,10 +42,11 @@
}
/**
- * testFiles
+ * TestFiles
*
- * Run simple syntax checks, comparing the phpcs output for the test
+ * Run simple syntax checks, comparing the phpcs output for the test.
* file against an expected output.
+ * @return array $tests The test string[].
*/
public static function testProvider() {
$tests = [];
@@ -73,16 +77,19 @@
*
* @dataProvider testProvider
*
- * @param string $file
- * @param string $standard
- * @param boolean $expectedOutputFile
+ * @param string $file The path string of file.
+ * @param string $standard The standard string.
+ * @param boolean $expectedOutputFile The path of expected file.
+ * @return void
*/
public function testFile( $file, $standard, $expectedOutputFile ) {
$outputStr = $this->prepareOutput( $this->helper->runPhpCs(
$file, $standard ) );
$expect = $this->prepareOutput( file_get_contents(
$expectedOutputFile ) );
$this->assertEquals( $expect, $outputStr );
}
-
+ /**
+ * @return array $tests The array of test.
+ */
public static function testFixProvider() {
$tests = self::testProvider();
foreach ( array_keys( $tests ) as $idx ) {
@@ -100,6 +107,10 @@
/**
* @dataProvider testFixProvider
+ * @param string $file The path of file.
+ * @param string $standard The standard string.
+ * @param string $fixedFile The path of fixed file.
+ * @return void
*/
public function testFix( $file, $standard, $fixedFile ) {
$outputStr = $this->helper->runPhpCbf( $file, $standard );
@@ -110,8 +121,8 @@
/**
* strip down the output to only the warnings
*
- * @param string $outputStr phpcs output
- * @return string
+ * @param string $outputStr PHPCS output.
+ * @return string $outputStr PHPCS output.
*/
private function prepareOutput( $outputStr ) {
if ( $outputStr ) {
@@ -125,9 +136,9 @@
}
/**
- * @param string[] $lines
- * @param bool $front When true strip from the front of array.
Otherwise the end.
- * @return string[]
+ * @param string[] $lines The array of lines.
+ * @param boolean $front When true strip from the front of array.
Otherwise the end.
+ * @return string[] $lines The processed array of lines.
*/
private function stripTwoDashLines( array $lines, $front = true ) {
$dashLines = 0;
diff --git a/MediaWiki/Tests/MediaWikiTestHelper.php
b/MediaWiki/Tests/MediaWikiTestHelper.php
index 38f1670..9491d6d 100644
--- a/MediaWiki/Tests/MediaWikiTestHelper.php
+++ b/MediaWiki/Tests/MediaWikiTestHelper.php
@@ -3,11 +3,19 @@
use org\bovigo\vfs\vfsStream;
class MediaWikiTestHelper extends TestHelper {
+ /**
+ * @return void
+ */
public function __construct() {
parent::__construct();
$this->vfsRoot = vfsStream::setup( 'root' );
}
+ /**
+ * @param string $file The path of file.
+ * @param string $standard The standard string.
+ * @return string
+ */
public function runPhpCbf( $file, $standard = '' ) {
if ( empty( $standard ) ) {
$standard = $this->rootDir . '/ruleset.xml';
diff --git a/MediaWiki/Tests/files/Commenting/commenting_function_fail.php
b/MediaWiki/Tests/files/Commenting/commenting_function_fail.php
new file mode 100644
index 0000000..04ad69b
--- /dev/null
+++ b/MediaWiki/Tests/files/Commenting/commenting_function_fail.php
@@ -0,0 +1,28 @@
+<?php
+
+class TestClass {
+
+ // Fail example start.
+
+ public function testNoDoc( $testVar ) {
+ return $testVar;
+ }
+
+ /**
+ * @param int $testVar This should start uppercase and end stop.
+ *
+ */
+ public function testNeedReturn( $testVar ) {
+ return $testVar;
+ }
+ /**
+ * @param int $testVar This is test.
+ * @param int $t For test.
+ * @return int $testVar This is test.
+ */
+ public function testSpaces( $testVar, $t ) {
+ return $testVar;
+ }
+
+ // Fail example end.
+}
diff --git
a/MediaWiki/Tests/files/Commenting/commenting_function_fail.php.expect
b/MediaWiki/Tests/files/Commenting/commenting_function_fail.php.expect
new file mode 100644
index 0000000..bd36a65
--- /dev/null
+++ b/MediaWiki/Tests/files/Commenting/commenting_function_fail.php.expect
@@ -0,0 +1,16 @@
+
+FILE: ...er/MediaWiki/Tests/files/Commenting/commenting_function_fail.php
+----------------------------------------------------------------------
+FOUND 4 ERRORS AFFECTING 4 LINES
+----------------------------------------------------------------------
+ 7 | ERROR | [ ] You must use "/**" style comments for a function
+ | | comment
+ 14 | ERROR | [ ] Missing @return tag in function comment
+ 19 | ERROR | [x] Expected 1 spaces after parameter name; 2 found
+ 20 | ERROR | [x] Expected 1 spaces after parameter name; 3 found
+----------------------------------------------------------------------
+PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
+----------------------------------------------------------------------
+
+Time: 18ms; Memory: 3.5Mb
+
diff --git
a/MediaWiki/Tests/files/Commenting/commenting_function_fail.php.fixed
b/MediaWiki/Tests/files/Commenting/commenting_function_fail.php.fixed
new file mode 100644
index 0000000..c35bed4
--- /dev/null
+++ b/MediaWiki/Tests/files/Commenting/commenting_function_fail.php.fixed
@@ -0,0 +1,28 @@
+<?php
+
+class TestClass {
+
+ // Fail example start.
+
+ public function testNoDoc( $testVar ) {
+ return $testVar;
+ }
+
+ /**
+ * @param int $testVar This should start uppercase and end stop.
+ *
+ */
+ public function testNeedReturn( $testVar ) {
+ return $testVar;
+ }
+ /**
+ * @param int $testVar This is test.
+ * @param int $t For test.
+ * @return int $testVar This is test.
+ */
+ public function testSpaces( $testVar, $t ) {
+ return $testVar;
+ }
+
+ // Fail example end.
+}
diff --git a/MediaWiki/Tests/files/Commenting/commenting_function_pass.php
b/MediaWiki/Tests/files/Commenting/commenting_function_pass.php
new file mode 100644
index 0000000..a8140b4
--- /dev/null
+++ b/MediaWiki/Tests/files/Commenting/commenting_function_pass.php
@@ -0,0 +1,13 @@
+<?php
+
+class TestFunctionClass {
+ /**
+ * Single Test function.
+ *
+ * @param int $testVar For test.
+ * @return int $testVar For test.
+ */
+ public function test( $testVar ) {
+ return $testVar;
+ }
+}
diff --git
a/MediaWiki/Tests/files/Commenting/commenting_function_pass.php.expect
b/MediaWiki/Tests/files/Commenting/commenting_function_pass.php.expect
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MediaWiki/Tests/files/Commenting/commenting_function_pass.php.expect
diff --git a/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php
b/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php
index 0b8c1f3..9ff1625 100644
--- a/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php
+++ b/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php
@@ -1,5 +1,9 @@
<?php
+/**
+ * @param boolean $a The test boolean.
+ * @return void
+ */
function wfFooFoo( $a ) {
if ( $a ) {
diff --git
a/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php.expect
b/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php.expect
index 5458bd7..460b38c 100644
--- a/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php.expect
+++ b/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php.expect
@@ -3,11 +3,11 @@
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
- 7 | WARNING | [x] Single space expected before "elseif"
- 10 | WARNING | [x] Single space expected before "else"
+ 11 | WARNING | [x] Single space expected before "elseif"
+ 14 | WARNING | [x] Single space expected before "else"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
-Time: 14ms; Memory: 3.25Mb
+Time: 15ms; Memory: 3.25Mb
diff --git
a/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php.fixed
b/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php.fixed
index 6c855ab..64a734e 100644
--- a/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php.fixed
+++ b/MediaWiki/Tests/files/ControlStructures/if_else_structure_fail.php.fixed
@@ -1,5 +1,9 @@
<?php
+/**
+ * @param boolean $a The test boolean.
+ * @return void
+ */
function wfFooFoo( $a ) {
if ( $a ) {
diff --git a/MediaWiki/Tests/files/ControlStructures/if_else_structure_pass.php
b/MediaWiki/Tests/files/ControlStructures/if_else_structure_pass.php
index 6c855ab..64a734e 100644
--- a/MediaWiki/Tests/files/ControlStructures/if_else_structure_pass.php
+++ b/MediaWiki/Tests/files/ControlStructures/if_else_structure_pass.php
@@ -1,5 +1,9 @@
<?php
+/**
+ * @param boolean $a The test boolean.
+ * @return void
+ */
function wfFooFoo( $a ) {
if ( $a ) {
diff --git
a/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php
b/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php
index f4bf8ef..a9656b2 100644
---
a/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php
+++
b/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php
@@ -1,5 +1,8 @@
someText<?php
// text before first php open
+/**
+ * @return void
+ */
function wfFoo() {
}
diff --git
a/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php.expect
b/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php.expect
index a4c6621..d9446f0 100644
---
a/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php.expect
+++
b/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php.expect
@@ -3,11 +3,11 @@
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
- 1 | ERROR | [ ] Extra character found before first <?
- 7 | WARNING | [x] Single space expected between "//" and comment
+ 1 | ERROR | [ ] Extra character found before first <?
+ 10 | WARNING | [x] Single space expected between "//" and comment
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
-Time: 11ms; Memory: 3.25Mb
+Time: 15ms; Memory: 3.25Mb
diff --git
a/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php.fixed
b/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php.fixed
index abc2e81..48654da 100644
---
a/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php.fixed
+++
b/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_fail.php.fixed
@@ -1,5 +1,8 @@
someText<?php
// text before first php open
+/**
+ * @return void
+ */
function wfFoo() {
}
diff --git
a/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_pass.php
b/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_pass.php
index 0b6d92d..9502848 100644
---
a/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_pass.php
+++
b/MediaWiki/Tests/files/ExtraCharacters/extra_characters_before_phpopen_tag_pass.php
@@ -1,5 +1,8 @@
<?php
// Valid php open tag
+/**
+ * @return void
+ */
function wfFoo() {
}
diff --git
a/MediaWiki/Tests/files/ExtraCharacters/valid_shebang_before_phpopen_tag_fail.php
b/MediaWiki/Tests/files/ExtraCharacters/valid_shebang_before_phpopen_tag_fail.php
index 9370829..13d37d3 100644
---
a/MediaWiki/Tests/files/ExtraCharacters/valid_shebang_before_phpopen_tag_fail.php
+++
b/MediaWiki/Tests/files/ExtraCharacters/valid_shebang_before_phpopen_tag_fail.php
@@ -2,6 +2,9 @@
#!/usr/bin/php
<?php
// invalid shebang
+/**
+ * @return void
+ */
function wfFoo() {
}
diff --git
a/MediaWiki/Tests/files/ExtraCharacters/valid_shebang_before_phpopen_tag_pass.php
b/MediaWiki/Tests/files/ExtraCharacters/valid_shebang_before_phpopen_tag_pass.php
index 22f5a0a..edf783c 100644
---
a/MediaWiki/Tests/files/ExtraCharacters/valid_shebang_before_phpopen_tag_pass.php
+++
b/MediaWiki/Tests/files/ExtraCharacters/valid_shebang_before_phpopen_tag_pass.php
@@ -1,6 +1,9 @@
#!/usr/bin/php
<?php
// Valid shebang before php open tag
+/**
+ * @return void
+ */
function wfFoo() {
}
diff --git a/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php
b/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php
index 4cb7d29..0671bf8 100644
--- a/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php
+++ b/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFooFoo () {
// The below should have capital after wg
global $wgsomething;
diff --git
a/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php.expect
b/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php.expect
index 6b0e65c..293dd10 100644
--- a/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php.expect
+++ b/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php.expect
@@ -3,13 +3,13 @@
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
- 3 | WARNING | [x] Space found before opening parenthesis of function
+ 6 | WARNING | [x] Space found before opening parenthesis of function
| | call
- 5 | ERROR | [ ] Global variable "$wgsomething" should use
+ 8 | ERROR | [ ] Global variable "$wgsomething" should use
| | CamelCase: "$wgWgsomething"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
-Time: 11ms; Memory: 3.25Mb
+Time: 15ms; Memory: 3.25Mb
diff --git
a/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php.fixed
b/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php.fixed
index 501e089..860d25f 100644
--- a/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php.fixed
+++ b/MediaWiki/Tests/files/NamingConventions/case_global_name_fail.php.fixed
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFooFoo() {
// The below should have capital after wg
global $wgsomething;
diff --git
a/MediaWiki/Tests/files/NamingConventions/wf_global_function_fail.php
b/MediaWiki/Tests/files/NamingConventions/wf_global_function_fail.php
index 0514cf7..9362217 100644
--- a/MediaWiki/Tests/files/NamingConventions/wf_global_function_fail.php
+++ b/MediaWiki/Tests/files/NamingConventions/wf_global_function_fail.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function foo() {
}
diff --git
a/MediaWiki/Tests/files/NamingConventions/wf_global_function_fail.php.expect
b/MediaWiki/Tests/files/NamingConventions/wf_global_function_fail.php.expect
index 3ab55a3..6220dd4 100644
--- a/MediaWiki/Tests/files/NamingConventions/wf_global_function_fail.php.expect
+++ b/MediaWiki/Tests/files/NamingConventions/wf_global_function_fail.php.expect
@@ -3,9 +3,9 @@
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
- 3 | ERROR | Global function "foo" is lacking a 'wf' prefix. Should
+ 6 | ERROR | Global function "foo" is lacking a 'wf' prefix. Should
| | be "wfFoo".
----------------------------------------------------------------------
-Time: 11ms; Memory: 3.25Mb
+Time: 14ms; Memory: 3.25Mb
diff --git
a/MediaWiki/Tests/files/NamingConventions/wf_global_function_pass.php
b/MediaWiki/Tests/files/NamingConventions/wf_global_function_pass.php
index c8b93eb..abf159f 100644
--- a/MediaWiki/Tests/files/NamingConventions/wf_global_function_pass.php
+++ b/MediaWiki/Tests/files/NamingConventions/wf_global_function_pass.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFoo() {
}
diff --git a/MediaWiki/Tests/files/NamingConventions/wf_namespace_pass.php
b/MediaWiki/Tests/files/NamingConventions/wf_namespace_pass.php
index f0ce08e..8d82faf 100644
--- a/MediaWiki/Tests/files/NamingConventions/wf_namespace_pass.php
+++ b/MediaWiki/Tests/files/NamingConventions/wf_namespace_pass.php
@@ -3,6 +3,9 @@
namespace FooBar;
// Doesn't start with "wf"
+/**
+ * @return void
+ */
function baz() {
$a = [];
}
diff --git a/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php
b/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php
index 7f160e7..4807899 100644
--- a/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php
+++ b/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFooFoo () {
// The first global is fine, the second isn't
global $wgContLang, $LocalInterwikis;
diff --git
a/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php.expect
b/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php.expect
index 80785c2..b6c7da1 100644
--- a/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php.expect
+++ b/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php.expect
@@ -3,13 +3,13 @@
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
- 3 | WARNING | [x] Space found before opening parenthesis of function
+ 6 | WARNING | [x] Space found before opening parenthesis of function
| | call
- 5 | ERROR | [ ] Global variable "$LocalInterwikis" is lacking 'wg'
+ 8 | ERROR | [ ] Global variable "$LocalInterwikis" is lacking 'wg'
| | prefix. Should be "$wgLocalInterwikis".
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
-Time: 12ms; Memory: 3.25Mb
+Time: 14ms; Memory: 3.25Mb
diff --git
a/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php.fixed
b/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php.fixed
index c05f938..ba570f3 100644
--- a/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php.fixed
+++ b/MediaWiki/Tests/files/NamingConventions/wg_global_name2_fail.php.fixed
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFooFoo() {
// The first global is fine, the second isn't
global $wgContLang, $LocalInterwikis;
diff --git a/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php
b/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php
index e93be5d..4ac4c72 100644
--- a/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php
+++ b/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFooFoo () {
// The below should start with wg...
global $someotherglobal;
diff --git
a/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php.expect
b/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php.expect
index e70e24f..fff8ff3 100644
--- a/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php.expect
+++ b/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php.expect
@@ -3,13 +3,13 @@
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
- 3 | WARNING | [x] Space found before opening parenthesis of function
+ 6 | WARNING | [x] Space found before opening parenthesis of function
| | call
- 5 | ERROR | [ ] Global variable "$someotherglobal" is lacking 'wg'
+ 8 | ERROR | [ ] Global variable "$someotherglobal" is lacking 'wg'
| | prefix. Should be "$wgSomeotherglobal".
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
-Time: 11ms; Memory: 3.25Mb
+Time: 15ms; Memory: 3.25Mb
diff --git
a/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php.fixed
b/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php.fixed
index 2f00882..08fb70a 100644
--- a/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php.fixed
+++ b/MediaWiki/Tests/files/NamingConventions/wg_global_name_fail.php.fixed
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFooFoo() {
// The below should start with wg...
global $someotherglobal;
diff --git a/MediaWiki/Tests/files/Usage/dir_usage_pass.php
b/MediaWiki/Tests/files/Usage/dir_usage_pass.php
index ec2e6a4..7a2753d 100644
--- a/MediaWiki/Tests/files/Usage/dir_usage_pass.php
+++ b/MediaWiki/Tests/files/Usage/dir_usage_pass.php
@@ -1,17 +1,31 @@
<?php
class FOO extends BAR {
+ /**
+ * @return void
+ */
function __construct() {
}
-
+ /**
+ * @param int $a Just for test.
+ * @return string
+ */
function dirname( $a ) {
return BAR::dirname( __FILE__ );
}
+ /**
+ * @param int $a Just for test.
+ * @return string
+ */
function foo( $a ) {
return BAR::foo( __FILE__ );
}
+ /**
+ * @param int $a Just for test.
+ * @return string
+ */
function bar( $a ) {
return BAR::bar( 0 );
}
diff --git
a/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php
b/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php
index 1289c34..0b3088f 100644
--- a/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php
+++ b/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFooFoo () {
// The global variable is not used
global $wgSomething;
diff --git
a/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php.expect
b/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php.expect
index 74af5cf..74a6fc9 100644
---
a/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php.expect
+++
b/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php.expect
@@ -3,12 +3,12 @@
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
- 3 | WARNING | [x] Space found before opening parenthesis of function
+ 6 | WARNING | [x] Space found before opening parenthesis of function
| | call
- 5 | WARNING | [ ] Global $wgSomething is never used.
+ 8 | WARNING | [ ] Global $wgSomething is never used.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
-Time: 11ms; Memory: 3.25Mb
+Time: 15ms; Memory: 3.25Mb
diff --git
a/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php.fixed
b/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php.fixed
index 4c47bdf..131052f 100644
---
a/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php.fixed
+++
b/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_fail.php.fixed
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFooFoo() {
// The global variable is not used
global $wgSomething;
diff --git
a/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_heredoc_pass.php
b/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_heredoc_pass.php
index 030470a..f24d01f 100644
---
a/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_heredoc_pass.php
+++
b/MediaWiki/Tests/files/VariableAnalysis/unused_global_variables_heredoc_pass.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFooFoo() {
global $wgSomething;
$foo = <<<PHP
diff --git
a/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_pass.php
b/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_pass.php
index 480abda..68e14fd 100644
--- a/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_pass.php
+++ b/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_pass.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFooFoo() {
global $wgSomething;
$foo = $wgSomething + 2;
diff --git
a/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_quote_string_pass.php
b/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_quote_string_pass.php
index 27018a3..106664f 100644
---
a/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_quote_string_pass.php
+++
b/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_quote_string_pass.php
@@ -1,5 +1,8 @@
<?php
+/**
+ * @return void
+ */
function wfFooFoo() {
global $wgSomething;
$foo = "foo$wgSomething";
diff --git
a/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_regression_pass.php
b/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_regression_pass.php
index c689ff9..1832f2a 100644
---
a/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_regression_pass.php
+++
b/MediaWiki/Tests/files/VariableAnalysis/used_global_variables_regression_pass.php
@@ -1,9 +1,15 @@
<?php
interface FooBar2 {
+ /**
+ * @return void
+ */
public function funcFooBar();
}
abstract class FooFoo {
+ /**
+ * @return void
+ */
abstract public function funcFooFoo();
}
diff --git a/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php
b/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php
index 870e252..15b0062 100644
--- a/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php
+++ b/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php
@@ -4,6 +4,9 @@
$b = false;
+/**
+ * @return void
+ */
function wfFoo() {
$a = 1;
diff --git
a/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php.expect
b/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php.expect
index a8852f1..34b1a9e 100644
--- a/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php.expect
+++ b/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php.expect
@@ -3,13 +3,13 @@
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
- 3 | ERROR | [x] Multiple empty lines should not exist in a row;
- | | found 2 consecutive empty lines
- 9 | ERROR | [x] Multiple empty lines should not exist in a row;
- | | found 2 consecutive empty lines
+ 3 | ERROR | [x] Multiple empty lines should not exist in a row;
+ | | found 2 consecutive empty lines
+ 12 | ERROR | [x] Multiple empty lines should not exist in a row;
+ | | found 2 consecutive empty lines
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
-Time: 11ms; Memory: 3.25Mb
+Time: 15ms; Memory: 3.25Mb
diff --git
a/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php.fixed
b/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php.fixed
index 528a829..4dc1cb9 100644
--- a/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php.fixed
+++ b/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_fail.php.fixed
@@ -3,6 +3,9 @@
$b = false;
+/**
+ * @return void
+ */
function wfFoo() {
$a = 1;
diff --git a/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_pass.php
b/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_pass.php
index 528a829..4dc1cb9 100644
--- a/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_pass.php
+++ b/MediaWiki/Tests/files/WhiteSpace/multiple_empty_lines_pass.php
@@ -3,6 +3,9 @@
$b = false;
+/**
+ * @return void
+ */
function wfFoo() {
$a = 1;
diff --git a/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php
b/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php
index 6f2e31f..bce7b35 100644
--- a/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php
+++ b/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php
@@ -1,4 +1,8 @@
<?php
+
+/**
+ * @return void
+ */
function wfBar () {
wfFoo ();
$a = array ();
diff --git
a/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php.expect
b/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php.expect
index 57b3b08..f3d7c71 100644
--- a/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php.expect
+++ b/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php.expect
@@ -3,16 +3,16 @@
----------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------
- 2 | WARNING | [x] Space found before opening parenthesis of function
+ 6 | WARNING | [x] Space found before opening parenthesis of function
| | call
- 3 | WARNING | [x] Space found before opening parenthesis of function
+ 7 | WARNING | [x] Space found before opening parenthesis of function
| | call
- 4 | ERROR | [x] Short array syntax must be used to define arrays
- 4 | WARNING | [x] Space found before opening parenthesis of function
+ 8 | ERROR | [x] Short array syntax must be used to define arrays
+ 8 | WARNING | [x] Space found before opening parenthesis of function
| | call
----------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
-Time: 12ms; Memory: 3.25Mb
+Time: 16ms; Memory: 3.25Mb
diff --git
a/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php.fixed
b/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php.fixed
index 8b8cfbd..e8788f7 100644
--- a/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php.fixed
+++ b/MediaWiki/Tests/files/WhiteSpace/space_before_parens_fail.php.fixed
@@ -1,4 +1,8 @@
<?php
+
+/**
+ * @return void
+ */
function wfBar() {
wfFoo();
$a = [];
diff --git a/MediaWiki/Tests/files/WhiteSpace/space_before_parens_pass.php
b/MediaWiki/Tests/files/WhiteSpace/space_before_parens_pass.php
index 8b8cfbd..1b0898e 100644
--- a/MediaWiki/Tests/files/WhiteSpace/space_before_parens_pass.php
+++ b/MediaWiki/Tests/files/WhiteSpace/space_before_parens_pass.php
@@ -1,4 +1,7 @@
<?php
+/**
+ * @return void
+ */
function wfBar() {
wfFoo();
$a = [];
diff --git a/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php
b/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php
index cfd3981..1e8c389 100644
--- a/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php
+++ b/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php
@@ -1,5 +1,10 @@
<?php
+/**
+ * @param int $a Just for test.
+ * @param int $b Just for test.
+ * @return void
+ */
function wfFooBar( $a, $b ) {
$a->foo($b);
$a->foo( $b );
diff --git
a/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php.expect
b/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php.expect
index 5bd8060..0166e57 100644
--- a/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php.expect
+++ b/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php.expect
@@ -1,21 +1,21 @@
FILE: ...fer/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php
----------------------------------------------------------------------
-FOUND 1 ERROR AND 7 WARNINGS AFFECTING 4 LINES
+FOUND 1 ERROR AND 9 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------
- 4 | WARNING | [x] Single space expected after opening parenthesis
- 4 | WARNING | [x] Single space expected before closing parenthesis
- 5 | WARNING | [x] Single space expected after opening parenthesis
- 5 | WARNING | [x] Single space expected before closing parenthesis
- 6 | WARNING | [x] Single space expected after opening parenthesis
- 6 | WARNING | [x] Single space expected before closing parenthesis
- 7 | ERROR | [x] Short array syntax must be used to define arrays
- 7 | WARNING | [x] Unnecessary space found within parentheses
- 12 | WARNING | [x] Single space expected after opening parenthesis
- 12 | WARNING | [x] Single space expected before closing parenthesis
+ 9 | WARNING | [x] Single space expected after opening parenthesis
+ 9 | WARNING | [x] Single space expected before closing parenthesis
+ 10 | WARNING | [x] Single space expected after opening parenthesis
+ 10 | WARNING | [x] Single space expected before closing parenthesis
+ 11 | WARNING | [x] Single space expected after opening parenthesis
+ 11 | WARNING | [x] Single space expected before closing parenthesis
+ 12 | ERROR | [x] Short array syntax must be used to define arrays
+ 12 | WARNING | [x] Unnecessary space found within parentheses
+ 17 | WARNING | [x] Single space expected after opening parenthesis
+ 17 | WARNING | [x] Single space expected before closing parenthesis
----------------------------------------------------------------------
-PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
+PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
-Time: 12ms; Memory: 3.25Mb
+Time: 16ms; Memory: 3.5Mb
diff --git a/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php.fixed
b/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php.fixed
index 6844019..be6996b 100644
--- a/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php.fixed
+++ b/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_fail.php.fixed
@@ -1,5 +1,10 @@
<?php
+/**
+ * @param int $a Just for test.
+ * @param int $b Just for test.
+ * @return void
+ */
function wfFooBar( $a, $b ) {
$a->foo( $b );
$a->foo( $b );
diff --git a/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_pass.php
b/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_pass.php
index 39c84bf..7cbeb54 100644
--- a/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_pass.php
+++ b/MediaWiki/Tests/files/WhiteSpace/spacey_parenthesis_pass.php
@@ -1,5 +1,10 @@
<?php
+/**
+ * @param object $arg Just for test.
+ * @param object $arg2 Just for test.
+ * @return void
+ */
function wfFooFoo( $arg, $arg2 ) {
$foo = [
// a comment
diff --git a/MediaWiki/Tests/files/generic_namespace_pass.php
b/MediaWiki/Tests/files/generic_namespace_pass.php
index 7dd9947..b172ecf 100644
--- a/MediaWiki/Tests/files/generic_namespace_pass.php
+++ b/MediaWiki/Tests/files/generic_namespace_pass.php
@@ -5,8 +5,8 @@
/**
* Some comment in a block :D
*
- * @param bool $outputtype
- * @param int $ts
+ * @param boolean $outputtype The type of output.
+ * @param int $ts The timestamp.
* @return null
*/
function namespacedFunction( $outputtype = true, $ts = 3 ) {
@@ -18,11 +18,17 @@
}
class FooBar extends AClass implements SomeInterface {
-
+ /**
+ * @param string $word The test word.
+ * @return string
+ */
public function feedThePanda( $word ) {
return 'something' . 'something else' . $word;
}
+ /**
+ * @return void
+ */
public function makeLegoBlocks() {
\SomeNamespace\namespacedFunction( false, 5 );
}
diff --git a/MediaWiki/Tests/files/generic_namespace_pass.php.fixed
b/MediaWiki/Tests/files/generic_namespace_pass.php.fixed
new file mode 100644
index 0000000..b172ecf
--- /dev/null
+++ b/MediaWiki/Tests/files/generic_namespace_pass.php.fixed
@@ -0,0 +1,35 @@
+<?php
+
+namespace SomeNamespace;
+
+/**
+ * Some comment in a block :D
+ *
+ * @param boolean $outputtype The type of output.
+ * @param int $ts The timestamp.
+ * @return null
+ */
+function namespacedFunction( $outputtype = true, $ts = 3 ) {
+ if ( is_null( $ts ) ) {
+ return null;
+ } else {
+ return wfTimestamp( $outputtype, $ts );
+ }
+}
+
+class FooBar extends AClass implements SomeInterface {
+ /**
+ * @param string $word The test word.
+ * @return string
+ */
+ public function feedThePanda( $word ) {
+ return 'something' . 'something else' . $word;
+ }
+
+ /**
+ * @return void
+ */
+ public function makeLegoBlocks() {
+ \SomeNamespace\namespacedFunction( false, 5 );
+ }
+}
diff --git a/MediaWiki/Tests/files/generic_pass.php
b/MediaWiki/Tests/files/generic_pass.php
index f4e7dc6..9489fd4 100644
--- a/MediaWiki/Tests/files/generic_pass.php
+++ b/MediaWiki/Tests/files/generic_pass.php
@@ -4,8 +4,8 @@
// https://www.mediawiki.org/wiki/Manual:Coding_conventions
/**
- * @param $outputtype
- * @param null $ts
+ * @param int $outputtype The type of output.
+ * @param null|int $ts The timestamp.
* @return null
*/
function wfTimestampOrNull( $outputtype = TS_UNIX, $ts = null ) {
@@ -34,7 +34,10 @@
private $foo = 'halalalalalaa';
public $var;
-
+ /**
+ * @param string $word The input string.
+ * @return boolean
+ */
public function iDoCaseStuff( $word ) {
switch ( $word ) {
case 'lorem':
@@ -53,6 +56,10 @@
|| preg_match( "/^\s*[+-]?0*[1-9]/", $bar );
}
+ /**
+ * @param string $word The input string.
+ * @return boolean
+ */
public function iDoCaseStuffTwo( $word ) {
switch ( $word ) {
case 'lorem':
@@ -67,7 +74,10 @@
}
return (bool)$bar;
}
-
+ /**
+ * @param string $par The test input.
+ * @return void
+ */
public function fooBarBaz( $par ) {
global $wgBarBarBar, $wgUser;
@@ -89,7 +99,10 @@
$foo = $par;
return $foo + $wgBarBarBar + $this->foo;
}
-
+ /**
+ * @param FooBar $baz The FooBar object.
+ * @return array $cat The merged array.
+ */
private function someFunction( FooBar $baz ) {
$foo = [
$baz,
diff --git a/TestHelper.php b/TestHelper.php
index c29fbbe..9d33f08 100644
--- a/TestHelper.php
+++ b/TestHelper.php
@@ -31,6 +31,9 @@
protected $phpcs;
+ /**
+ * @return void
+ */
public function __construct() {
$this->rootDir = dirname( __DIR__ );
$this->dirName = basename( $this->rootDir );
@@ -40,9 +43,9 @@
/**
* Run PHPCS on a file.
*
- * @param string $file to run.
- * @param string $standard to run against
- * @return string The output from phpcs.
+ * @param string $file To run.
+ * @param string $standard To run against.
+ * @return string $result The output from phpcs.
*/
public function runPhpCs( $file, $standard = '' ) {
if ( empty( $standard ) ) {
--
To view, visit https://gerrit.wikimedia.org/r/291489
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4918bd59a07490952f5d17242631ab36c350a99e
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: Lethexie <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Lethexie <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits