From 661df0b7c29414d922ab08eaeaf67c6948e23055 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sat, 25 Nov 2017 19:13:28 -0500 Subject: [PATCH 01/14] Add sniff for 'void' in @return tags --- WordPress-Docs/ruleset.xml | 2 + .../Sniffs/Commenting/NoReturnVoidSniff.php | 100 ++++++++++++++++++ .../Tests/Commenting/NoReturnVoidUnitTest.inc | 49 +++++++++ .../Tests/Commenting/NoReturnVoidUnitTest.php | 46 ++++++++ 4 files changed, 197 insertions(+) create mode 100755 WordPress/Sniffs/Commenting/NoReturnVoidSniff.php create mode 100755 WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc create mode 100755 WordPress/Tests/Commenting/NoReturnVoidUnitTest.php diff --git a/WordPress-Docs/ruleset.xml b/WordPress-Docs/ruleset.xml index 05f0ec87db..130ffccbd3 100644 --- a/WordPress-Docs/ruleset.xml +++ b/WordPress-Docs/ruleset.xml @@ -116,4 +116,6 @@ + + diff --git a/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php b/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php new file mode 100755 index 0000000000..204503e29b --- /dev/null +++ b/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php @@ -0,0 +1,100 @@ +phpcsFile->findPrevious( + array_merge( Tokens::$methodPrefixes, array( T_WHITESPACE ) ), + ( $stackPtr - 1 ), + null, + true + ); + + if ( T_DOC_COMMENT_CLOSE_TAG !== $this->tokens[ $commentEnd ]['code'] ) { + // Invalid function comment. Handled elsewhere. + return; + } + + $commentStart = $this->tokens[ $commentEnd ]['comment_opener']; + + $returnTag = null; + + foreach ( $this->tokens[ $commentStart ]['comment_tags'] as $tag ) { + if ( '@return' === $this->tokens[ $tag ]['content'] ) { + $returnTag = $tag; + // Multiple return tags are invalid, but flagged elsewhere. + break; + } + } + + if ( ! $returnTag ) { + return; + } + + $returnCommentPtr = ( $returnTag + 2 ); + $returnComment = $this->tokens[ $returnCommentPtr ]; + + if ( empty( $returnComment['content'] ) || T_DOC_COMMENT_STRING !== $returnComment['code'] ) { + // Invalid return comment. Handled elsewhere. + return; + } + + // Extracted from PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff::processReturn(). + preg_match( '`^((?:\|?(?:array\([^\)]*\)|[\\\\a-z0-9\[\]]+))*)( .*)?`i', $returnComment['content'], $commentParts ); + + if ( empty( $commentParts[1] ) ) { + return; + } + + $returnTypes = array_unique( explode( '|', $commentParts[1] ) ); + + foreach ( $returnTypes as $type ) { + if ( 'void' === $type ) { + $this->phpcsFile->addError( + sprintf( '`@return void` should not be used outside of the default bundled themes', $type ), + $returnTag, + 'ReturnVoidFound' + ); + + break; + } + } + } + +} diff --git a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc new file mode 100755 index 0000000000..db010eaf82 --- /dev/null +++ b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc @@ -0,0 +1,49 @@ + => + */ + public function getErrorList() { + return array( + 5 => 1, + 14 => 1, + 23 => 1, + 32 => 1, + ); + } + + /** + * Returns the lines where warnings should occur. + * + * @return array => + */ + public function getWarningList() { + return array(); + } + +} // End class. From 1d126035821b6f9007aff85fb7e8502ecdbd3385 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sat, 25 Nov 2017 19:27:48 -0500 Subject: [PATCH 02/14] Fix alignment errors --- WordPress/Sniffs/Commenting/NoReturnVoidSniff.php | 2 +- WordPress/Tests/Commenting/NoReturnVoidUnitTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php b/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php index 204503e29b..a40dbc3302 100755 --- a/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php +++ b/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php @@ -68,7 +68,7 @@ public function process_token( $stackPtr ) { } $returnCommentPtr = ( $returnTag + 2 ); - $returnComment = $this->tokens[ $returnCommentPtr ]; + $returnComment = $this->tokens[ $returnCommentPtr ]; if ( empty( $returnComment['content'] ) || T_DOC_COMMENT_STRING !== $returnComment['code'] ) { // Invalid return comment. Handled elsewhere. diff --git a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php index bc75e5b646..cba638c036 100755 --- a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php +++ b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php @@ -27,7 +27,7 @@ class NoReturnVoidUnitTest extends AbstractSniffUnitTest { */ public function getErrorList() { return array( - 5 => 1, + 5 => 1, 14 => 1, 23 => 1, 32 => 1, From 91278c18797ca3bd194750bf40dacc8803409b80 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sat, 25 Nov 2017 20:04:35 -0500 Subject: [PATCH 03/14] Fix unnecessary double quotes --- WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc index db010eaf82..2206244fd7 100755 --- a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc +++ b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc @@ -5,7 +5,7 @@ * @return void */ function no_return_void() { - echo "test"; + echo 'test'; } /** @@ -14,7 +14,7 @@ function no_return_void() { * @return void|string */ function no_return_void_string() { - echo "test"; + echo 'test'; } /** @@ -23,7 +23,7 @@ function no_return_void_string() { * @return string|void */ function no_return_string_void() { - echo "test"; + echo 'test'; } /** @@ -32,7 +32,7 @@ function no_return_string_void() { * @return array|string|void */ function no_return_array_string_void() { - echo "test"; + echo 'test'; } /** @@ -45,5 +45,5 @@ function return_string() { return 'bar'; } - echo "test"; + echo 'test'; } From 544d0d533b25a8ba4d2efe8a18967d09ebf101e9 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Mon, 27 Nov 2017 12:57:33 -0500 Subject: [PATCH 04/14] Remove extra `sprintf()` --- WordPress/Sniffs/Commenting/NoReturnVoidSniff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php b/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php index a40dbc3302..1f9696f1cd 100755 --- a/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php +++ b/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php @@ -87,7 +87,7 @@ public function process_token( $stackPtr ) { foreach ( $returnTypes as $type ) { if ( 'void' === $type ) { $this->phpcsFile->addError( - sprintf( '`@return void` should not be used outside of the default bundled themes', $type ), + '`@return void` should not be used outside of the default bundled themes', $returnTag, 'ReturnVoidFound' ); From aad472041a22de0005f107f6070e0320ce1c36d9 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Tue, 28 Nov 2017 22:59:42 -0500 Subject: [PATCH 05/14] Reference handbook rule in ruleset --- WordPress-Docs/ruleset.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress-Docs/ruleset.xml b/WordPress-Docs/ruleset.xml index 130ffccbd3..ec6418d59a 100644 --- a/WordPress-Docs/ruleset.xml +++ b/WordPress-Docs/ruleset.xml @@ -117,5 +117,6 @@ + From 41ce582616d2d128051e786b9791c56971118057 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Tue, 28 Nov 2017 23:00:47 -0500 Subject: [PATCH 06/14] Update @since tags --- WordPress/Sniffs/Commenting/NoReturnVoidSniff.php | 2 +- WordPress/Tests/Commenting/NoReturnVoidUnitTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php b/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php index 1f9696f1cd..590586a772 100755 --- a/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php +++ b/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php @@ -19,7 +19,7 @@ * * @package WPCS\WordPressCodingStandards * - * @since X.Y.Z + * @since 0.16.0 */ class NoReturnVoidSniff extends Sniff { diff --git a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php index cba638c036..bf039ccef2 100755 --- a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php +++ b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php @@ -16,7 +16,7 @@ * * @package WPCS\WordPressCodingStandards * - * @since X.Y.Z + * @since 0.16.0 */ class NoReturnVoidUnitTest extends AbstractSniffUnitTest { From 1e40e6ab9011de0f31043cf52f3f041c5305a263 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Tue, 28 Nov 2017 23:10:08 -0500 Subject: [PATCH 07/14] Replace extended error description with a recommendation --- WordPress/Sniffs/Commenting/NoReturnVoidSniff.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php b/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php index 590586a772..dce5e98f72 100755 --- a/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php +++ b/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php @@ -86,8 +86,14 @@ public function process_token( $stackPtr ) { foreach ( $returnTypes as $type ) { if ( 'void' === $type ) { + $error = '`@return void` should not be used.'; + + $recommendation = ( count( $returnTypes ) > 1 ) + ? 'Remove it from the list of return types instead' + : 'Omit the `@return` tag instead'; + $this->phpcsFile->addError( - '`@return void` should not be used outside of the default bundled themes', + "$error $recommendation", $returnTag, 'ReturnVoidFound' ); From ddc1b0d9e131bb50543ab270cf3faa65315d87f0 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Tue, 28 Nov 2017 23:16:34 -0500 Subject: [PATCH 08/14] Add tests with @return tag comments --- .../Tests/Commenting/NoReturnVoidUnitTest.inc | 36 +++++++++++++++++++ .../Tests/Commenting/NoReturnVoidUnitTest.php | 4 +++ 2 files changed, 40 insertions(+) diff --git a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc index 2206244fd7..930f10e32d 100755 --- a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc +++ b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc @@ -8,6 +8,15 @@ function no_return_void() { echo 'test'; } +/** + * Return types should not be void. + * + * @return void Nothing. + */ +function no_return_void_comment() { + echo 'test'; +} + /** * Return types should not be void. * @@ -17,6 +26,15 @@ function no_return_void_string() { echo 'test'; } +/** + * Return types should not be void. + * + * @return void|string Nothing + */ +function no_return_void_string_comment() { + echo 'test'; +} + /** * Return types should not be void. * @@ -26,6 +44,15 @@ function no_return_string_void() { echo 'test'; } +/** + * Return types should not be void. + * + * @return string|void Maybe nothing. + */ +function no_return_string_void_comment() { + echo 'test'; +} + /** * Return types should not be void. * @@ -35,6 +62,15 @@ function no_return_array_string_void() { echo 'test'; } +/** + * Return types should not be void. + * + * @return array|string|void Maybe nothing. + */ +function no_return_array_string_void_comment() { + echo 'test'; +} + /** * Return types should not be void. * diff --git a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php index bf039ccef2..3bacd4b0f0 100755 --- a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php +++ b/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php @@ -31,6 +31,10 @@ public function getErrorList() { 14 => 1, 23 => 1, 32 => 1, + 41 => 1, + 50 => 1, + 59 => 1, + 68 => 1, ); } From f8467b2d3c24173da1233e1719d43214a30fcbcd Mon Sep 17 00:00:00 2001 From: David Herrera Date: Tue, 28 Nov 2017 23:31:56 -0500 Subject: [PATCH 09/14] Remove `@return void` from internal docs --- .../AbstractArrayAssignmentRestrictionsSniff.php | 2 -- WordPress/AbstractClassRestrictionsSniff.php | 8 ++++---- WordPress/AbstractFunctionParameterSniff.php | 12 ++++++------ WordPress/AbstractFunctionRestrictionsSniff.php | 12 ++++++------ WordPress/AbstractVariableRestrictionsSniff.php | 4 ++-- WordPress/Sniff.php | 8 ++++---- WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php | 2 -- .../Sniffs/Arrays/ArrayDeclarationSpacingSniff.php | 6 ------ WordPress/Sniffs/Arrays/ArrayIndentationSniff.php | 2 -- .../Arrays/ArrayKeySpacingRestrictionsSniff.php | 2 -- .../Sniffs/Arrays/CommaAfterArrayItemSniff.php | 2 -- .../Arrays/MultipleStatementAlignmentSniff.php | 10 ++++------ WordPress/Sniffs/CSRF/NonceVerificationSniff.php | 4 ---- .../Sniffs/Classes/ClassInstantiationSniff.php | 2 -- .../CodeAnalysis/AssignmentInConditionSniff.php | 2 -- .../Sniffs/DB/PreparedSQLPlaceholdersSniff.php | 2 -- WordPress/Sniffs/Files/FileNameSniff.php | 4 ++-- .../NamingConventions/PrefixAllGlobalsSniff.php | 14 ++++++-------- .../NamingConventions/ValidFunctionNameSniff.php | 4 ---- .../NamingConventions/ValidHookNameSniff.php | 2 -- .../NamingConventions/ValidVariableNameSniff.php | 8 -------- WordPress/Sniffs/PHP/DiscouragedFunctionsSniff.php | 2 -- WordPress/Sniffs/PHP/StrictComparisonsSniff.php | 2 -- WordPress/Sniffs/PHP/StrictInArraySniff.php | 4 ---- WordPress/Sniffs/PHP/YodaConditionsSniff.php | 2 -- WordPress/Sniffs/VIP/AdminBarRemovalSniff.php | 10 ++-------- WordPress/Sniffs/VIP/CronIntervalSniff.php | 2 -- WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php | 4 ---- WordPress/Sniffs/VIP/PluginMenuSlugSniff.php | 2 -- WordPress/Sniffs/VIP/SessionVariableUsageSniff.php | 2 -- WordPress/Sniffs/VIP/SlowDBQuerySniff.php | 4 ++-- .../Sniffs/VIP/SuperGlobalInputUsageSniff.php | 2 -- .../Sniffs/VIP/ValidatedSanitizedInputSniff.php | 4 ---- .../Sniffs/Variables/GlobalVariablesSniff.php | 4 ---- WordPress/Sniffs/WP/CapitalPDangitSniff.php | 4 ++-- WordPress/Sniffs/WP/DeprecatedClassesSniff.php | 2 -- WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php | 2 -- WordPress/Sniffs/WP/DeprecatedParametersSniff.php | 2 -- WordPress/Sniffs/WP/DiscouragedConstantsSniff.php | 8 ++------ WordPress/Sniffs/WP/EnqueuedResourcesSniff.php | 2 -- WordPress/Sniffs/WP/I18nSniff.php | 5 ----- WordPress/Sniffs/WP/PreparedSQLSniff.php | 4 ++-- .../ArbitraryParenthesesSpacingSniff.php | 4 ++-- .../WhiteSpace/CastStructureSpacingSniff.php | 2 -- .../WhiteSpace/ControlStructureSpacingSniff.php | 2 -- .../Sniffs/WhiteSpace/SemicolonSpacingSniff.php | 2 +- WordPress/Sniffs/XSS/EscapeOutputSniff.php | 6 ++---- .../Tests/Arrays/ArrayIndentationUnitTest.php | 2 -- .../Arrays/MultipleStatementAlignmentUnitTest.php | 2 -- WordPress/Tests/WP/I18nUnitTest.php | 2 -- .../WhiteSpace/DisallowInlineTabsUnitTest.php | 2 -- .../WhiteSpace/PrecisionAlignmentUnitTest.php | 2 -- 52 files changed, 49 insertions(+), 162 deletions(-) diff --git a/WordPress/AbstractArrayAssignmentRestrictionsSniff.php b/WordPress/AbstractArrayAssignmentRestrictionsSniff.php index 349995eaf7..5c3cd4a2b7 100644 --- a/WordPress/AbstractArrayAssignmentRestrictionsSniff.php +++ b/WordPress/AbstractArrayAssignmentRestrictionsSniff.php @@ -124,8 +124,6 @@ protected function setup_groups() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/AbstractClassRestrictionsSniff.php b/WordPress/AbstractClassRestrictionsSniff.php index dd3cef36c8..769fc9e8b6 100644 --- a/WordPress/AbstractClassRestrictionsSniff.php +++ b/WordPress/AbstractClassRestrictionsSniff.php @@ -86,8 +86,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { // Reset the temporary storage before processing the token. @@ -167,8 +167,8 @@ public function is_targetted_token( $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function check_for_matches( $stackPtr ) { $skip_to = array(); diff --git a/WordPress/AbstractFunctionParameterSniff.php b/WordPress/AbstractFunctionParameterSniff.php index b201354aa1..2794e78959 100644 --- a/WordPress/AbstractFunctionParameterSniff.php +++ b/WordPress/AbstractFunctionParameterSniff.php @@ -63,8 +63,8 @@ public function getGroups() { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_matched_token( $stackPtr, $group_name, $matched_content ) { @@ -87,8 +87,8 @@ public function process_matched_token( $stackPtr, $group_name, $matched_content * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ abstract public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ); @@ -102,8 +102,8 @@ abstract public function process_parameters( $stackPtr, $group_name, $matched_co * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_no_parameters( $stackPtr, $group_name, $matched_content ) { return; diff --git a/WordPress/AbstractFunctionRestrictionsSniff.php b/WordPress/AbstractFunctionRestrictionsSniff.php index cba5f6bbb7..ff9fc9a835 100644 --- a/WordPress/AbstractFunctionRestrictionsSniff.php +++ b/WordPress/AbstractFunctionRestrictionsSniff.php @@ -173,8 +173,8 @@ protected function setup_groups( $key ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { @@ -248,8 +248,8 @@ public function is_targetted_token( $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function check_for_matches( $stackPtr ) { $token_content = strtolower( $this->tokens[ $stackPtr ]['content'] ); @@ -287,8 +287,8 @@ public function check_for_matches( $stackPtr ) { * @param string $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_matched_token( $stackPtr, $group_name, $matched_content ) { diff --git a/WordPress/AbstractVariableRestrictionsSniff.php b/WordPress/AbstractVariableRestrictionsSniff.php index 5ed71212ee..f2df37d146 100644 --- a/WordPress/AbstractVariableRestrictionsSniff.php +++ b/WordPress/AbstractVariableRestrictionsSniff.php @@ -129,8 +129,8 @@ protected function setup_groups() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniff.php b/WordPress/Sniff.php index 01d2e19f02..5d695e5f1e 100644 --- a/WordPress/Sniff.php +++ b/WordPress/Sniff.php @@ -877,8 +877,8 @@ abstract class Sniff implements PHPCS_Sniff { * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process( File $phpcsFile, $stackPtr ) { $this->init( $phpcsFile ); @@ -892,8 +892,8 @@ public function process( File $phpcsFile, $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ abstract public function process_token( $stackPtr ); diff --git a/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php b/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php index 2f9899f1c7..3d3fcea633 100644 --- a/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -53,8 +53,6 @@ public function register() { * * @param \PHP_CodeSniffer\Files\File $phpcsFile A PHP_CodeSniffer file. * @param int $stackPtr The position of the token. - * - * @return void */ public function process( File $phpcsFile, $stackPtr ) {} diff --git a/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php b/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php index 6adfbec963..9fa2dce160 100644 --- a/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php +++ b/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php @@ -84,8 +84,6 @@ public function register() { * be in the `processSingleLineArray()` method. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { /* @@ -176,8 +174,6 @@ public function process_token( $stackPtr ) { * @param int $stackPtr The position of the current token in the stack. * @param int $opener The position of the array opener. * @param int $closer The position of the array closer. - * - * @return void */ protected function process_single_line_array( $stackPtr, $opener, $closer ) { /* @@ -333,8 +329,6 @@ protected function process_single_line_array( $stackPtr, $opener, $closer ) { * @param int $stackPtr The position of the current token in the stack. * @param int $opener The position of the array opener. * @param int $closer The position of the array closer. - * - * @return void */ protected function process_multi_line_array( $stackPtr, $opener, $closer ) { /* diff --git a/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php b/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php index c62e2ff12e..c5e9341c3c 100644 --- a/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php +++ b/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php @@ -85,8 +85,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { if ( ! isset( $this->tab_width ) ) { diff --git a/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php b/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php index 73e38aa686..e541486569 100644 --- a/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php +++ b/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php @@ -41,8 +41,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php b/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php index 6d90d35cf2..05f480dfb8 100644 --- a/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php +++ b/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php @@ -47,8 +47,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { /* diff --git a/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php b/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php index 43d8b9dd09..89d8c6af87 100644 --- a/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php +++ b/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php @@ -160,8 +160,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { /* @@ -207,8 +207,8 @@ public function process_token( $stackPtr ) { * @param int $opener The position of the array opener. * @param int $closer The position of the array closer. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ protected function process_single_line_array( $stackPtr, $items, $opener, $closer ) { /* @@ -259,8 +259,6 @@ protected function process_single_line_array( $stackPtr, $items, $opener, $close * @param array $items Info array containing information on each array item. * @param int $opener The position of the array opener. * @param int $closer The position of the array closer. - * - * @return void */ protected function process_multi_line_array( $stackPtr, $items, $opener, $closer ) { diff --git a/WordPress/Sniffs/CSRF/NonceVerificationSniff.php b/WordPress/Sniffs/CSRF/NonceVerificationSniff.php index 3eff3780f5..10c75d71ae 100644 --- a/WordPress/Sniffs/CSRF/NonceVerificationSniff.php +++ b/WordPress/Sniffs/CSRF/NonceVerificationSniff.php @@ -125,8 +125,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { @@ -168,8 +166,6 @@ public function process_token( $stackPtr ) { * Merge custom functions provided via a custom ruleset with the defaults, if we haven't already. * * @since 0.11.0 Split out from the `process()` method. - * - * @return void */ protected function mergeFunctionLists() { if ( $this->customNonceVerificationFunctions !== $this->addedCustomFunctions['nonce'] ) { diff --git a/WordPress/Sniffs/Classes/ClassInstantiationSniff.php b/WordPress/Sniffs/Classes/ClassInstantiationSniff.php index 12e2043de4..08c4e58426 100644 --- a/WordPress/Sniffs/Classes/ClassInstantiationSniff.php +++ b/WordPress/Sniffs/Classes/ClassInstantiationSniff.php @@ -86,8 +86,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { // Make sure we have the right token, JS vs PHP. diff --git a/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php b/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php index e5585b1b53..65fd938813 100644 --- a/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php +++ b/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php @@ -86,8 +86,6 @@ public function register() { * @since 0.14.0 * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php b/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php index 58af287883..8de5cd2890 100644 --- a/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php +++ b/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php @@ -165,8 +165,6 @@ public function register() { * @since 0.14.0 * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/Files/FileNameSniff.php b/WordPress/Sniffs/Files/FileNameSniff.php index 716b7910bb..fc22d7c7c6 100644 --- a/WordPress/Sniffs/Files/FileNameSniff.php +++ b/WordPress/Sniffs/Files/FileNameSniff.php @@ -130,8 +130,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php index 25d862ffa2..fe0dc2648e 100644 --- a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +++ b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php @@ -151,8 +151,8 @@ public function getGroups() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { /* @@ -332,8 +332,8 @@ public function process_token( $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ protected function process_variable_variable( $stackPtr ) { static $indicators = array( @@ -429,8 +429,8 @@ protected function process_variable_variable( $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ protected function process_variable_assignment( $stackPtr ) { @@ -567,8 +567,6 @@ protected function process_variable_assignment( $stackPtr ) { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. - * - * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { diff --git a/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php index 73073e9ae3..3d952cb0ba 100644 --- a/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -59,8 +59,6 @@ class ValidFunctionNameSniff extends PHPCS_PEAR_ValidFunctionNameSniff { * @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 ) { $functionName = $phpcsFile->getDeclarationName( $stackPtr ); @@ -106,8 +104,6 @@ protected function processTokenOutsideScope( File $phpcsFile, $stackPtr ) { * @param int $stackPtr The position where this token was * found. * @param int $currScope The position of the current scope. - * - * @return void */ protected function processTokenWithinScope( File $phpcsFile, $stackPtr, $currScope ) { $methodName = $phpcsFile->getDeclarationName( $stackPtr ); diff --git a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php index ef20800f6b..866fd1f015 100644 --- a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php @@ -84,8 +84,6 @@ public function getGroups() { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. - * - * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { // Ignore deprecated hook names. diff --git a/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php index d57924c9bf..5d900bea90 100644 --- a/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -129,8 +129,6 @@ class ValidVariableNameSniff extends PHPCS_AbstractVariableSniff { * @param \PHP_CodeSniffer\Files\File $phpcs_file The file being scanned. * @param int $stack_ptr The position of the current token in the * stack passed in $tokens. - * - * @return void */ protected function processVariable( File $phpcs_file, $stack_ptr ) { @@ -215,8 +213,6 @@ protected function processVariable( File $phpcs_file, $stack_ptr ) { * @param \PHP_CodeSniffer\Files\File $phpcs_file The file being scanned. * @param int $stack_ptr The position of the current token in the * stack passed in $tokens. - * - * @return void */ protected function processMemberVar( File $phpcs_file, $stack_ptr ) { @@ -249,8 +245,6 @@ protected function processMemberVar( File $phpcs_file, $stack_ptr ) { * @param \PHP_CodeSniffer\Files\File $phpcs_file The file being scanned. * @param int $stack_ptr The position of the double quoted * string. - * - * @return void */ protected function processVariableInString( File $phpcs_file, $stack_ptr ) { @@ -299,8 +293,6 @@ public static function isSnakeCase( $var_name ) { * @since 0.10.0 * * @param \PHP_CodeSniffer\Files\File $phpcs_file The file being scanned. - * - * @return void */ protected function mergeWhiteList( File $phpcs_file ) { if ( $this->customPropertiesWhitelist !== $this->addedCustomProperties['properties'] diff --git a/WordPress/Sniffs/PHP/DiscouragedFunctionsSniff.php b/WordPress/Sniffs/PHP/DiscouragedFunctionsSniff.php index 763ab86b24..940434cfb7 100644 --- a/WordPress/Sniffs/PHP/DiscouragedFunctionsSniff.php +++ b/WordPress/Sniffs/PHP/DiscouragedFunctionsSniff.php @@ -55,8 +55,6 @@ public function register() { * * @param \PHP_CodeSniffer\Files\File $phpcsFile A PHP_CodeSniffer file. * @param int $stackPtr The position of the token. - * - * @return void */ public function process( File $phpcsFile, $stackPtr ) {} diff --git a/WordPress/Sniffs/PHP/StrictComparisonsSniff.php b/WordPress/Sniffs/PHP/StrictComparisonsSniff.php index ee81527044..a048ad956b 100644 --- a/WordPress/Sniffs/PHP/StrictComparisonsSniff.php +++ b/WordPress/Sniffs/PHP/StrictComparisonsSniff.php @@ -43,8 +43,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/PHP/StrictInArraySniff.php b/WordPress/Sniffs/PHP/StrictInArraySniff.php index 6feb1b26fd..004d24174e 100644 --- a/WordPress/Sniffs/PHP/StrictInArraySniff.php +++ b/WordPress/Sniffs/PHP/StrictInArraySniff.php @@ -68,8 +68,6 @@ class StrictInArraySniff extends AbstractFunctionParameterSniff { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. - * - * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { // Check if the strict check is actually needed. @@ -109,8 +107,6 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p * @param int $stackPtr The position of the current token in the stack. * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. - * - * @return void */ public function process_no_parameters( $stackPtr, $group_name, $matched_content ) { $this->phpcsFile->addError( 'Missing arguments to %s.', $stackPtr, 'MissingArguments', array( $matched_content ) ); diff --git a/WordPress/Sniffs/PHP/YodaConditionsSniff.php b/WordPress/Sniffs/PHP/YodaConditionsSniff.php index f66b3471af..189cd24bb5 100644 --- a/WordPress/Sniffs/PHP/YodaConditionsSniff.php +++ b/WordPress/Sniffs/PHP/YodaConditionsSniff.php @@ -65,8 +65,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/VIP/AdminBarRemovalSniff.php b/WordPress/Sniffs/VIP/AdminBarRemovalSniff.php index e692ff0979..94e33f1d83 100644 --- a/WordPress/Sniffs/VIP/AdminBarRemovalSniff.php +++ b/WordPress/Sniffs/VIP/AdminBarRemovalSniff.php @@ -171,8 +171,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { @@ -212,8 +212,6 @@ public function process_token( $stackPtr ) { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. - * - * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { $error = false; @@ -258,8 +256,6 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p * * @param int $stackPtr The position of the current token in the stack. * @param string $file_name The file name of the current file being processed. - * - * @return void */ public function process_text_for_style( $stackPtr, $file_name ) { $content = trim( $this->tokens[ $stackPtr ]['content'] ); @@ -352,8 +348,6 @@ public function process_text_for_style( $stackPtr, $file_name ) { * @since 0.11.0 * * @param int $stackPtr The position of the current token in the stack passed in $tokens. - * - * @return void */ protected function process_css_style( $stackPtr ) { if ( ! isset( $this->target_css_properties[ $this->tokens[ $stackPtr ]['content'] ] ) ) { diff --git a/WordPress/Sniffs/VIP/CronIntervalSniff.php b/WordPress/Sniffs/VIP/CronIntervalSniff.php index 968243c9e3..c98a803660 100644 --- a/WordPress/Sniffs/VIP/CronIntervalSniff.php +++ b/WordPress/Sniffs/VIP/CronIntervalSniff.php @@ -71,8 +71,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { $token = $this->tokens[ $stackPtr ]; diff --git a/WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php b/WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php index 6458fd45b2..8ca987efd7 100644 --- a/WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php +++ b/WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php @@ -109,8 +109,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { @@ -227,8 +225,6 @@ public function process_token( $stackPtr ) { * Merge custom functions provided via a custom ruleset with the defaults, if we haven't already. * * @since 0.11.0 Split out from the `process()` method. - * - * @return void */ protected function mergeFunctionLists() { if ( ! isset( $this->methods['all'] ) ) { diff --git a/WordPress/Sniffs/VIP/PluginMenuSlugSniff.php b/WordPress/Sniffs/VIP/PluginMenuSlugSniff.php index 655d9e7965..6a557b087d 100644 --- a/WordPress/Sniffs/VIP/PluginMenuSlugSniff.php +++ b/WordPress/Sniffs/VIP/PluginMenuSlugSniff.php @@ -69,8 +69,6 @@ class PluginMenuSlugSniff extends AbstractFunctionParameterSniff { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. - * - * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { foreach ( $this->target_functions[ $matched_content ] as $position ) { diff --git a/WordPress/Sniffs/VIP/SessionVariableUsageSniff.php b/WordPress/Sniffs/VIP/SessionVariableUsageSniff.php index 74edbef6d4..5799d9553a 100644 --- a/WordPress/Sniffs/VIP/SessionVariableUsageSniff.php +++ b/WordPress/Sniffs/VIP/SessionVariableUsageSniff.php @@ -43,8 +43,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { if ( '$_SESSION' === $this->tokens[ $stackPtr ]['content'] ) { diff --git a/WordPress/Sniffs/VIP/SlowDBQuerySniff.php b/WordPress/Sniffs/VIP/SlowDBQuerySniff.php index d3b022fe0a..f51009f81e 100644 --- a/WordPress/Sniffs/VIP/SlowDBQuerySniff.php +++ b/WordPress/Sniffs/VIP/SlowDBQuerySniff.php @@ -53,8 +53,8 @@ public function getGroups() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/VIP/SuperGlobalInputUsageSniff.php b/WordPress/Sniffs/VIP/SuperGlobalInputUsageSniff.php index c3b7737250..06c753218f 100644 --- a/WordPress/Sniffs/VIP/SuperGlobalInputUsageSniff.php +++ b/WordPress/Sniffs/VIP/SuperGlobalInputUsageSniff.php @@ -40,8 +40,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { // Check for global input variable. diff --git a/WordPress/Sniffs/VIP/ValidatedSanitizedInputSniff.php b/WordPress/Sniffs/VIP/ValidatedSanitizedInputSniff.php index d51744ed86..c471b137d4 100644 --- a/WordPress/Sniffs/VIP/ValidatedSanitizedInputSniff.php +++ b/WordPress/Sniffs/VIP/ValidatedSanitizedInputSniff.php @@ -83,8 +83,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { @@ -158,8 +156,6 @@ function ( $symbol ) { * Merge custom functions provided via a custom ruleset with the defaults, if we haven't already. * * @since 0.11.0 Split out from the `process()` method. - * - * @return void */ protected function mergeFunctionLists() { if ( $this->customSanitizingFunctions !== $this->addedCustomFunctions['sanitize'] ) { diff --git a/WordPress/Sniffs/Variables/GlobalVariablesSniff.php b/WordPress/Sniffs/Variables/GlobalVariablesSniff.php index 9ec1db806e..a69a03da9d 100644 --- a/WordPress/Sniffs/Variables/GlobalVariablesSniff.php +++ b/WordPress/Sniffs/Variables/GlobalVariablesSniff.php @@ -42,8 +42,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { $token = $this->tokens[ $stackPtr ]; @@ -165,8 +163,6 @@ public function process_token( $stackPtr ) { * is not done from within a test method. * * @param int $stackPtr The position of the token to throw the error for. - * - * @return void */ public function maybe_add_error( $stackPtr ) { if ( ! $this->is_token_in_test_method( $stackPtr ) && ! $this->has_whitelist_comment( 'override', $stackPtr ) ) { diff --git a/WordPress/Sniffs/WP/CapitalPDangitSniff.php b/WordPress/Sniffs/WP/CapitalPDangitSniff.php index ca42817f48..7ff8a392a1 100644 --- a/WordPress/Sniffs/WP/CapitalPDangitSniff.php +++ b/WordPress/Sniffs/WP/CapitalPDangitSniff.php @@ -124,8 +124,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/WP/DeprecatedClassesSniff.php b/WordPress/Sniffs/WP/DeprecatedClassesSniff.php index 1e46dcf320..1860e299b0 100644 --- a/WordPress/Sniffs/WP/DeprecatedClassesSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedClassesSniff.php @@ -77,8 +77,6 @@ public function getGroups() { * @param array $group_name The name of the group which was matched. Will * always be 'deprecated_functions'. * @param string $matched_content The token content (class name) which was matched. - * - * @return void */ public function process_matched_token( $stackPtr, $group_name, $matched_content ) { diff --git a/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php b/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php index 23c1d1d037..2a770571ca 100644 --- a/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php @@ -1326,8 +1326,6 @@ public function getGroups() { * @param array $group_name The name of the group which was matched. Will * always be 'deprecated_functions'. * @param string $matched_content The token content (function name) which was matched. - * - * @return void */ public function process_matched_token( $stackPtr, $group_name, $matched_content ) { diff --git a/WordPress/Sniffs/WP/DeprecatedParametersSniff.php b/WordPress/Sniffs/WP/DeprecatedParametersSniff.php index 30794b7aac..aaafd66dee 100644 --- a/WordPress/Sniffs/WP/DeprecatedParametersSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedParametersSniff.php @@ -275,8 +275,6 @@ class DeprecatedParametersSniff extends AbstractFunctionParameterSniff { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. - * - * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { diff --git a/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php b/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php index 7e47b042ea..7559a5014c 100644 --- a/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php +++ b/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php @@ -82,8 +82,8 @@ class DiscouragedConstantsSniff extends AbstractFunctionParameterSniff { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { if ( isset( $this->target_functions[ strtolower( $this->tokens[ $stackPtr ]['content'] ) ] ) ) { @@ -103,8 +103,6 @@ public function process_token( $stackPtr ) { * @since 0.14.0 * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_arbitrary_tstring( $stackPtr ) { $content = $this->tokens[ $stackPtr ]['content']; @@ -191,8 +189,6 @@ public function process_arbitrary_tstring( $stackPtr ) { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. - * - * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { $function_name = strtolower( $matched_content ); diff --git a/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php b/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php index 965a28abe7..ee70ee2956 100644 --- a/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php +++ b/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php @@ -38,8 +38,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { $token = $this->tokens[ $stackPtr ]; diff --git a/WordPress/Sniffs/WP/I18nSniff.php b/WordPress/Sniffs/WP/I18nSniff.php index 1967701d0b..fe0cc62f6c 100644 --- a/WordPress/Sniffs/WP/I18nSniff.php +++ b/WordPress/Sniffs/WP/I18nSniff.php @@ -158,8 +158,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stack_ptr The position of the current token in the stack. - * - * @return void */ public function process_token( $stack_ptr ) { $token = $this->tokens[ $stack_ptr ]; @@ -485,7 +483,6 @@ protected function check_argument_tokens( $context ) { * @param int $stack_ptr The position of the current token in the stack. * @param array $single_context Single context (@todo needs better description). * @param array $plural_context Plural context (@todo needs better description). - * @return void */ protected function compare_single_and_plural_arguments( $stack_ptr, $single_context, $plural_context ) { $single_content = $single_context['tokens'][0]['content']; @@ -519,7 +516,6 @@ protected function compare_single_and_plural_arguments( $stack_ptr, $single_cont * Check the string itself for problems. * * @param array $context Context (@todo needs better description). - * @return void */ protected function check_text( $context ) { $stack_ptr = $context['stack_ptr']; @@ -593,7 +589,6 @@ protected function check_text( $context ) { * * @param int $stack_ptr The position of the gettext call token in the stack. * @param array $args The function arguments. - * @return void */ protected function check_for_translator_comment( $stack_ptr, $args ) { foreach ( $args as $arg ) { diff --git a/WordPress/Sniffs/WP/PreparedSQLSniff.php b/WordPress/Sniffs/WP/PreparedSQLSniff.php index ff21f7a849..a654dca0b2 100644 --- a/WordPress/Sniffs/WP/PreparedSQLSniff.php +++ b/WordPress/Sniffs/WP/PreparedSQLSniff.php @@ -116,8 +116,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php index e01df14e5c..62ea4c7933 100644 --- a/WordPress/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php @@ -101,8 +101,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php index 75b420145f..b7a92c1d6c 100755 --- a/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php @@ -40,8 +40,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index 2c70b77e62..3da54ead8b 100644 --- a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -108,8 +108,6 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * - * @return void */ public function process_token( $stackPtr ) { $this->spaces_before_closure_open_paren = (int) $this->spaces_before_closure_open_paren; diff --git a/WordPress/Sniffs/WhiteSpace/SemicolonSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/SemicolonSpacingSniff.php index 147331862d..f2a97be6db 100644 --- a/WordPress/Sniffs/WhiteSpace/SemicolonSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/SemicolonSpacingSniff.php @@ -29,7 +29,7 @@ class SemicolonSpacingSniff extends PHPCS_Squiz_SemicolonSpacingSniff { * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return void|int + * @return int */ public function process( File $phpcsFile, $stackPtr ) { $tokens = $phpcsFile->getTokens(); diff --git a/WordPress/Sniffs/XSS/EscapeOutputSniff.php b/WordPress/Sniffs/XSS/EscapeOutputSniff.php index 8c0c76b4c5..9f01ca2452 100644 --- a/WordPress/Sniffs/XSS/EscapeOutputSniff.php +++ b/WordPress/Sniffs/XSS/EscapeOutputSniff.php @@ -189,8 +189,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { @@ -455,8 +455,6 @@ public function process_token( $stackPtr ) { * Merge custom functions provided via a custom ruleset with the defaults, if we haven't already. * * @since 0.11.0 Split out from the `process()` method. - * - * @return void */ protected function mergeFunctionLists() { if ( $this->customEscapingFunctions !== $this->addedCustomFunctions['escape'] diff --git a/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php b/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php index b13a53fc59..bbcc4d890e 100644 --- a/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php +++ b/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php @@ -53,8 +53,6 @@ public function getCliValues( $testFile ) { * * @param string $testFile The name of the file being tested. * @param \PHP_CodeSniffer\Config $config The config data for the test run. - * - * @return void */ public function setCliValues( $testFile, $config ) { // Tab width setting is only needed for the tabbed file. diff --git a/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php b/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php index 371aea87ae..c538aab240 100644 --- a/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php +++ b/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php @@ -56,8 +56,6 @@ public function getCliValues( $testFile ) { * * @param string $testFile The name of the file being tested. * @param \PHP_CodeSniffer\Config $config The config data for the test run. - * - * @return void */ public function setCliValues( $testFile, $config ) { // Tab width setting is only needed for the tabbed file. diff --git a/WordPress/Tests/WP/I18nUnitTest.php b/WordPress/Tests/WP/I18nUnitTest.php index 4eff21a0bc..fd677eb9e4 100644 --- a/WordPress/Tests/WP/I18nUnitTest.php +++ b/WordPress/Tests/WP/I18nUnitTest.php @@ -47,8 +47,6 @@ public function getCliValues( $testFile ) { * * @param string $testFile The name of the file being tested. * @param \PHP_CodeSniffer\Config $config The config data for the test run. - * - * @return void */ public function setCliValues( $testFile, $config ) { // Test overruling the text domain from the command line for one test file. diff --git a/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php b/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php index 8761423c85..e7865bac7c 100644 --- a/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php +++ b/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php @@ -48,8 +48,6 @@ public function getCliValues( $testFile ) { * * @param string $testFile The name of the file being tested. * @param \PHP_CodeSniffer\Config $config The config data for the test run. - * - * @return void */ public function setCliValues( $testFile, $config ) { $config->tabWidth = $this->tab_width; diff --git a/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php b/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php index 57fcbbd428..aebfebf723 100644 --- a/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php +++ b/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php @@ -47,8 +47,6 @@ public function getCliValues( $testFile ) { * * @param string $testFile The name of the file being tested. * @param \PHP_CodeSniffer\Config $config The config data for the test run. - * - * @return void */ public function setCliValues( $testFile, $config ) { $config->tabWidth = $this->tab_width; From 1f41eecc7aae3eeebfb6df22283803d48a452729 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sat, 9 Dec 2017 21:31:10 -0500 Subject: [PATCH 10/14] Revert "Remove `@return void` from internal docs" This reverts commit f8467b2d3c24173da1233e1719d43214a30fcbcd. --- .../AbstractArrayAssignmentRestrictionsSniff.php | 2 ++ WordPress/AbstractClassRestrictionsSniff.php | 8 ++++---- WordPress/AbstractFunctionParameterSniff.php | 12 ++++++------ WordPress/AbstractFunctionRestrictionsSniff.php | 12 ++++++------ WordPress/AbstractVariableRestrictionsSniff.php | 4 ++-- WordPress/Sniff.php | 8 ++++---- WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php | 2 ++ .../Sniffs/Arrays/ArrayDeclarationSpacingSniff.php | 6 ++++++ WordPress/Sniffs/Arrays/ArrayIndentationSniff.php | 2 ++ .../Arrays/ArrayKeySpacingRestrictionsSniff.php | 2 ++ .../Sniffs/Arrays/CommaAfterArrayItemSniff.php | 2 ++ .../Arrays/MultipleStatementAlignmentSniff.php | 10 ++++++---- WordPress/Sniffs/CSRF/NonceVerificationSniff.php | 4 ++++ .../Sniffs/Classes/ClassInstantiationSniff.php | 2 ++ .../CodeAnalysis/AssignmentInConditionSniff.php | 2 ++ .../Sniffs/DB/PreparedSQLPlaceholdersSniff.php | 2 ++ WordPress/Sniffs/Files/FileNameSniff.php | 4 ++-- .../NamingConventions/PrefixAllGlobalsSniff.php | 14 ++++++++------ .../NamingConventions/ValidFunctionNameSniff.php | 4 ++++ .../NamingConventions/ValidHookNameSniff.php | 2 ++ .../NamingConventions/ValidVariableNameSniff.php | 8 ++++++++ WordPress/Sniffs/PHP/DiscouragedFunctionsSniff.php | 2 ++ WordPress/Sniffs/PHP/StrictComparisonsSniff.php | 2 ++ WordPress/Sniffs/PHP/StrictInArraySniff.php | 4 ++++ WordPress/Sniffs/PHP/YodaConditionsSniff.php | 2 ++ WordPress/Sniffs/VIP/AdminBarRemovalSniff.php | 10 ++++++++-- WordPress/Sniffs/VIP/CronIntervalSniff.php | 2 ++ WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php | 4 ++++ WordPress/Sniffs/VIP/PluginMenuSlugSniff.php | 2 ++ WordPress/Sniffs/VIP/SessionVariableUsageSniff.php | 2 ++ WordPress/Sniffs/VIP/SlowDBQuerySniff.php | 4 ++-- .../Sniffs/VIP/SuperGlobalInputUsageSniff.php | 2 ++ .../Sniffs/VIP/ValidatedSanitizedInputSniff.php | 4 ++++ .../Sniffs/Variables/GlobalVariablesSniff.php | 4 ++++ WordPress/Sniffs/WP/CapitalPDangitSniff.php | 4 ++-- WordPress/Sniffs/WP/DeprecatedClassesSniff.php | 2 ++ WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php | 2 ++ WordPress/Sniffs/WP/DeprecatedParametersSniff.php | 2 ++ WordPress/Sniffs/WP/DiscouragedConstantsSniff.php | 8 ++++++-- WordPress/Sniffs/WP/EnqueuedResourcesSniff.php | 2 ++ WordPress/Sniffs/WP/I18nSniff.php | 5 +++++ WordPress/Sniffs/WP/PreparedSQLSniff.php | 4 ++-- .../ArbitraryParenthesesSpacingSniff.php | 4 ++-- .../WhiteSpace/CastStructureSpacingSniff.php | 2 ++ .../WhiteSpace/ControlStructureSpacingSniff.php | 2 ++ .../Sniffs/WhiteSpace/SemicolonSpacingSniff.php | 2 +- WordPress/Sniffs/XSS/EscapeOutputSniff.php | 6 ++++-- .../Tests/Arrays/ArrayIndentationUnitTest.php | 2 ++ .../Arrays/MultipleStatementAlignmentUnitTest.php | 2 ++ WordPress/Tests/WP/I18nUnitTest.php | 2 ++ .../WhiteSpace/DisallowInlineTabsUnitTest.php | 2 ++ .../WhiteSpace/PrecisionAlignmentUnitTest.php | 2 ++ 52 files changed, 162 insertions(+), 49 deletions(-) diff --git a/WordPress/AbstractArrayAssignmentRestrictionsSniff.php b/WordPress/AbstractArrayAssignmentRestrictionsSniff.php index 5c3cd4a2b7..349995eaf7 100644 --- a/WordPress/AbstractArrayAssignmentRestrictionsSniff.php +++ b/WordPress/AbstractArrayAssignmentRestrictionsSniff.php @@ -124,6 +124,8 @@ protected function setup_groups() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/AbstractClassRestrictionsSniff.php b/WordPress/AbstractClassRestrictionsSniff.php index 769fc9e8b6..dd3cef36c8 100644 --- a/WordPress/AbstractClassRestrictionsSniff.php +++ b/WordPress/AbstractClassRestrictionsSniff.php @@ -86,8 +86,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { // Reset the temporary storage before processing the token. @@ -167,8 +167,8 @@ public function is_targetted_token( $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function check_for_matches( $stackPtr ) { $skip_to = array(); diff --git a/WordPress/AbstractFunctionParameterSniff.php b/WordPress/AbstractFunctionParameterSniff.php index 2794e78959..b201354aa1 100644 --- a/WordPress/AbstractFunctionParameterSniff.php +++ b/WordPress/AbstractFunctionParameterSniff.php @@ -63,8 +63,8 @@ public function getGroups() { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_matched_token( $stackPtr, $group_name, $matched_content ) { @@ -87,8 +87,8 @@ public function process_matched_token( $stackPtr, $group_name, $matched_content * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ abstract public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ); @@ -102,8 +102,8 @@ abstract public function process_parameters( $stackPtr, $group_name, $matched_co * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_no_parameters( $stackPtr, $group_name, $matched_content ) { return; diff --git a/WordPress/AbstractFunctionRestrictionsSniff.php b/WordPress/AbstractFunctionRestrictionsSniff.php index ff9fc9a835..cba5f6bbb7 100644 --- a/WordPress/AbstractFunctionRestrictionsSniff.php +++ b/WordPress/AbstractFunctionRestrictionsSniff.php @@ -173,8 +173,8 @@ protected function setup_groups( $key ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { @@ -248,8 +248,8 @@ public function is_targetted_token( $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function check_for_matches( $stackPtr ) { $token_content = strtolower( $this->tokens[ $stackPtr ]['content'] ); @@ -287,8 +287,8 @@ public function check_for_matches( $stackPtr ) { * @param string $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_matched_token( $stackPtr, $group_name, $matched_content ) { diff --git a/WordPress/AbstractVariableRestrictionsSniff.php b/WordPress/AbstractVariableRestrictionsSniff.php index f2df37d146..5ed71212ee 100644 --- a/WordPress/AbstractVariableRestrictionsSniff.php +++ b/WordPress/AbstractVariableRestrictionsSniff.php @@ -129,8 +129,8 @@ protected function setup_groups() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniff.php b/WordPress/Sniff.php index 5d695e5f1e..01d2e19f02 100644 --- a/WordPress/Sniff.php +++ b/WordPress/Sniff.php @@ -877,8 +877,8 @@ abstract class Sniff implements PHPCS_Sniff { * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process( File $phpcsFile, $stackPtr ) { $this->init( $phpcsFile ); @@ -892,8 +892,8 @@ public function process( File $phpcsFile, $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ abstract public function process_token( $stackPtr ); diff --git a/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php b/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php index 3d3fcea633..2f9899f1c7 100644 --- a/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -53,6 +53,8 @@ public function register() { * * @param \PHP_CodeSniffer\Files\File $phpcsFile A PHP_CodeSniffer file. * @param int $stackPtr The position of the token. + * + * @return void */ public function process( File $phpcsFile, $stackPtr ) {} diff --git a/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php b/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php index 9fa2dce160..6adfbec963 100644 --- a/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php +++ b/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php @@ -84,6 +84,8 @@ public function register() { * be in the `processSingleLineArray()` method. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { /* @@ -174,6 +176,8 @@ public function process_token( $stackPtr ) { * @param int $stackPtr The position of the current token in the stack. * @param int $opener The position of the array opener. * @param int $closer The position of the array closer. + * + * @return void */ protected function process_single_line_array( $stackPtr, $opener, $closer ) { /* @@ -329,6 +333,8 @@ protected function process_single_line_array( $stackPtr, $opener, $closer ) { * @param int $stackPtr The position of the current token in the stack. * @param int $opener The position of the array opener. * @param int $closer The position of the array closer. + * + * @return void */ protected function process_multi_line_array( $stackPtr, $opener, $closer ) { /* diff --git a/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php b/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php index c5e9341c3c..c62e2ff12e 100644 --- a/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php +++ b/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php @@ -85,6 +85,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { if ( ! isset( $this->tab_width ) ) { diff --git a/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php b/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php index e541486569..73e38aa686 100644 --- a/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php +++ b/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php @@ -41,6 +41,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php b/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php index 05f480dfb8..6d90d35cf2 100644 --- a/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php +++ b/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php @@ -47,6 +47,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { /* diff --git a/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php b/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php index 89d8c6af87..43d8b9dd09 100644 --- a/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php +++ b/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php @@ -160,8 +160,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { /* @@ -207,8 +207,8 @@ public function process_token( $stackPtr ) { * @param int $opener The position of the array opener. * @param int $closer The position of the array closer. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ protected function process_single_line_array( $stackPtr, $items, $opener, $closer ) { /* @@ -259,6 +259,8 @@ protected function process_single_line_array( $stackPtr, $items, $opener, $close * @param array $items Info array containing information on each array item. * @param int $opener The position of the array opener. * @param int $closer The position of the array closer. + * + * @return void */ protected function process_multi_line_array( $stackPtr, $items, $opener, $closer ) { diff --git a/WordPress/Sniffs/CSRF/NonceVerificationSniff.php b/WordPress/Sniffs/CSRF/NonceVerificationSniff.php index 10c75d71ae..3eff3780f5 100644 --- a/WordPress/Sniffs/CSRF/NonceVerificationSniff.php +++ b/WordPress/Sniffs/CSRF/NonceVerificationSniff.php @@ -125,6 +125,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { @@ -166,6 +168,8 @@ public function process_token( $stackPtr ) { * Merge custom functions provided via a custom ruleset with the defaults, if we haven't already. * * @since 0.11.0 Split out from the `process()` method. + * + * @return void */ protected function mergeFunctionLists() { if ( $this->customNonceVerificationFunctions !== $this->addedCustomFunctions['nonce'] ) { diff --git a/WordPress/Sniffs/Classes/ClassInstantiationSniff.php b/WordPress/Sniffs/Classes/ClassInstantiationSniff.php index 08c4e58426..12e2043de4 100644 --- a/WordPress/Sniffs/Classes/ClassInstantiationSniff.php +++ b/WordPress/Sniffs/Classes/ClassInstantiationSniff.php @@ -86,6 +86,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { // Make sure we have the right token, JS vs PHP. diff --git a/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php b/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php index 65fd938813..e5585b1b53 100644 --- a/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php +++ b/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php @@ -86,6 +86,8 @@ public function register() { * @since 0.14.0 * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php b/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php index 8de5cd2890..58af287883 100644 --- a/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php +++ b/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php @@ -165,6 +165,8 @@ public function register() { * @since 0.14.0 * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/Files/FileNameSniff.php b/WordPress/Sniffs/Files/FileNameSniff.php index fc22d7c7c6..716b7910bb 100644 --- a/WordPress/Sniffs/Files/FileNameSniff.php +++ b/WordPress/Sniffs/Files/FileNameSniff.php @@ -130,8 +130,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php index fe0dc2648e..25d862ffa2 100644 --- a/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +++ b/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php @@ -151,8 +151,8 @@ public function getGroups() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { /* @@ -332,8 +332,8 @@ public function process_token( $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ protected function process_variable_variable( $stackPtr ) { static $indicators = array( @@ -429,8 +429,8 @@ protected function process_variable_variable( $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ protected function process_variable_assignment( $stackPtr ) { @@ -567,6 +567,8 @@ protected function process_variable_assignment( $stackPtr ) { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. + * + * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { diff --git a/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php index 3d952cb0ba..73073e9ae3 100644 --- a/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -59,6 +59,8 @@ class ValidFunctionNameSniff extends PHPCS_PEAR_ValidFunctionNameSniff { * @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 ) { $functionName = $phpcsFile->getDeclarationName( $stackPtr ); @@ -104,6 +106,8 @@ protected function processTokenOutsideScope( File $phpcsFile, $stackPtr ) { * @param int $stackPtr The position where this token was * found. * @param int $currScope The position of the current scope. + * + * @return void */ protected function processTokenWithinScope( File $phpcsFile, $stackPtr, $currScope ) { $methodName = $phpcsFile->getDeclarationName( $stackPtr ); diff --git a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php index 866fd1f015..ef20800f6b 100644 --- a/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php @@ -84,6 +84,8 @@ public function getGroups() { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. + * + * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { // Ignore deprecated hook names. diff --git a/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php b/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php index 5d900bea90..d57924c9bf 100644 --- a/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -129,6 +129,8 @@ class ValidVariableNameSniff extends PHPCS_AbstractVariableSniff { * @param \PHP_CodeSniffer\Files\File $phpcs_file The file being scanned. * @param int $stack_ptr The position of the current token in the * stack passed in $tokens. + * + * @return void */ protected function processVariable( File $phpcs_file, $stack_ptr ) { @@ -213,6 +215,8 @@ protected function processVariable( File $phpcs_file, $stack_ptr ) { * @param \PHP_CodeSniffer\Files\File $phpcs_file The file being scanned. * @param int $stack_ptr The position of the current token in the * stack passed in $tokens. + * + * @return void */ protected function processMemberVar( File $phpcs_file, $stack_ptr ) { @@ -245,6 +249,8 @@ protected function processMemberVar( File $phpcs_file, $stack_ptr ) { * @param \PHP_CodeSniffer\Files\File $phpcs_file The file being scanned. * @param int $stack_ptr The position of the double quoted * string. + * + * @return void */ protected function processVariableInString( File $phpcs_file, $stack_ptr ) { @@ -293,6 +299,8 @@ public static function isSnakeCase( $var_name ) { * @since 0.10.0 * * @param \PHP_CodeSniffer\Files\File $phpcs_file The file being scanned. + * + * @return void */ protected function mergeWhiteList( File $phpcs_file ) { if ( $this->customPropertiesWhitelist !== $this->addedCustomProperties['properties'] diff --git a/WordPress/Sniffs/PHP/DiscouragedFunctionsSniff.php b/WordPress/Sniffs/PHP/DiscouragedFunctionsSniff.php index 940434cfb7..763ab86b24 100644 --- a/WordPress/Sniffs/PHP/DiscouragedFunctionsSniff.php +++ b/WordPress/Sniffs/PHP/DiscouragedFunctionsSniff.php @@ -55,6 +55,8 @@ public function register() { * * @param \PHP_CodeSniffer\Files\File $phpcsFile A PHP_CodeSniffer file. * @param int $stackPtr The position of the token. + * + * @return void */ public function process( File $phpcsFile, $stackPtr ) {} diff --git a/WordPress/Sniffs/PHP/StrictComparisonsSniff.php b/WordPress/Sniffs/PHP/StrictComparisonsSniff.php index a048ad956b..ee81527044 100644 --- a/WordPress/Sniffs/PHP/StrictComparisonsSniff.php +++ b/WordPress/Sniffs/PHP/StrictComparisonsSniff.php @@ -43,6 +43,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/PHP/StrictInArraySniff.php b/WordPress/Sniffs/PHP/StrictInArraySniff.php index 004d24174e..6feb1b26fd 100644 --- a/WordPress/Sniffs/PHP/StrictInArraySniff.php +++ b/WordPress/Sniffs/PHP/StrictInArraySniff.php @@ -68,6 +68,8 @@ class StrictInArraySniff extends AbstractFunctionParameterSniff { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. + * + * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { // Check if the strict check is actually needed. @@ -107,6 +109,8 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p * @param int $stackPtr The position of the current token in the stack. * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. + * + * @return void */ public function process_no_parameters( $stackPtr, $group_name, $matched_content ) { $this->phpcsFile->addError( 'Missing arguments to %s.', $stackPtr, 'MissingArguments', array( $matched_content ) ); diff --git a/WordPress/Sniffs/PHP/YodaConditionsSniff.php b/WordPress/Sniffs/PHP/YodaConditionsSniff.php index 189cd24bb5..f66b3471af 100644 --- a/WordPress/Sniffs/PHP/YodaConditionsSniff.php +++ b/WordPress/Sniffs/PHP/YodaConditionsSniff.php @@ -65,6 +65,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/VIP/AdminBarRemovalSniff.php b/WordPress/Sniffs/VIP/AdminBarRemovalSniff.php index 94e33f1d83..e692ff0979 100644 --- a/WordPress/Sniffs/VIP/AdminBarRemovalSniff.php +++ b/WordPress/Sniffs/VIP/AdminBarRemovalSniff.php @@ -171,8 +171,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { @@ -212,6 +212,8 @@ public function process_token( $stackPtr ) { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. + * + * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { $error = false; @@ -256,6 +258,8 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p * * @param int $stackPtr The position of the current token in the stack. * @param string $file_name The file name of the current file being processed. + * + * @return void */ public function process_text_for_style( $stackPtr, $file_name ) { $content = trim( $this->tokens[ $stackPtr ]['content'] ); @@ -348,6 +352,8 @@ public function process_text_for_style( $stackPtr, $file_name ) { * @since 0.11.0 * * @param int $stackPtr The position of the current token in the stack passed in $tokens. + * + * @return void */ protected function process_css_style( $stackPtr ) { if ( ! isset( $this->target_css_properties[ $this->tokens[ $stackPtr ]['content'] ] ) ) { diff --git a/WordPress/Sniffs/VIP/CronIntervalSniff.php b/WordPress/Sniffs/VIP/CronIntervalSniff.php index c98a803660..968243c9e3 100644 --- a/WordPress/Sniffs/VIP/CronIntervalSniff.php +++ b/WordPress/Sniffs/VIP/CronIntervalSniff.php @@ -71,6 +71,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { $token = $this->tokens[ $stackPtr ]; diff --git a/WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php b/WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php index 8ca987efd7..6458fd45b2 100644 --- a/WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php +++ b/WordPress/Sniffs/VIP/DirectDatabaseQuerySniff.php @@ -109,6 +109,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { @@ -225,6 +227,8 @@ public function process_token( $stackPtr ) { * Merge custom functions provided via a custom ruleset with the defaults, if we haven't already. * * @since 0.11.0 Split out from the `process()` method. + * + * @return void */ protected function mergeFunctionLists() { if ( ! isset( $this->methods['all'] ) ) { diff --git a/WordPress/Sniffs/VIP/PluginMenuSlugSniff.php b/WordPress/Sniffs/VIP/PluginMenuSlugSniff.php index 6a557b087d..655d9e7965 100644 --- a/WordPress/Sniffs/VIP/PluginMenuSlugSniff.php +++ b/WordPress/Sniffs/VIP/PluginMenuSlugSniff.php @@ -69,6 +69,8 @@ class PluginMenuSlugSniff extends AbstractFunctionParameterSniff { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. + * + * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { foreach ( $this->target_functions[ $matched_content ] as $position ) { diff --git a/WordPress/Sniffs/VIP/SessionVariableUsageSniff.php b/WordPress/Sniffs/VIP/SessionVariableUsageSniff.php index 5799d9553a..74edbef6d4 100644 --- a/WordPress/Sniffs/VIP/SessionVariableUsageSniff.php +++ b/WordPress/Sniffs/VIP/SessionVariableUsageSniff.php @@ -43,6 +43,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { if ( '$_SESSION' === $this->tokens[ $stackPtr ]['content'] ) { diff --git a/WordPress/Sniffs/VIP/SlowDBQuerySniff.php b/WordPress/Sniffs/VIP/SlowDBQuerySniff.php index f51009f81e..d3b022fe0a 100644 --- a/WordPress/Sniffs/VIP/SlowDBQuerySniff.php +++ b/WordPress/Sniffs/VIP/SlowDBQuerySniff.php @@ -53,8 +53,8 @@ public function getGroups() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/VIP/SuperGlobalInputUsageSniff.php b/WordPress/Sniffs/VIP/SuperGlobalInputUsageSniff.php index 06c753218f..c3b7737250 100644 --- a/WordPress/Sniffs/VIP/SuperGlobalInputUsageSniff.php +++ b/WordPress/Sniffs/VIP/SuperGlobalInputUsageSniff.php @@ -40,6 +40,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { // Check for global input variable. diff --git a/WordPress/Sniffs/VIP/ValidatedSanitizedInputSniff.php b/WordPress/Sniffs/VIP/ValidatedSanitizedInputSniff.php index c471b137d4..d51744ed86 100644 --- a/WordPress/Sniffs/VIP/ValidatedSanitizedInputSniff.php +++ b/WordPress/Sniffs/VIP/ValidatedSanitizedInputSniff.php @@ -83,6 +83,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { @@ -156,6 +158,8 @@ function ( $symbol ) { * Merge custom functions provided via a custom ruleset with the defaults, if we haven't already. * * @since 0.11.0 Split out from the `process()` method. + * + * @return void */ protected function mergeFunctionLists() { if ( $this->customSanitizingFunctions !== $this->addedCustomFunctions['sanitize'] ) { diff --git a/WordPress/Sniffs/Variables/GlobalVariablesSniff.php b/WordPress/Sniffs/Variables/GlobalVariablesSniff.php index a69a03da9d..9ec1db806e 100644 --- a/WordPress/Sniffs/Variables/GlobalVariablesSniff.php +++ b/WordPress/Sniffs/Variables/GlobalVariablesSniff.php @@ -42,6 +42,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { $token = $this->tokens[ $stackPtr ]; @@ -163,6 +165,8 @@ public function process_token( $stackPtr ) { * is not done from within a test method. * * @param int $stackPtr The position of the token to throw the error for. + * + * @return void */ public function maybe_add_error( $stackPtr ) { if ( ! $this->is_token_in_test_method( $stackPtr ) && ! $this->has_whitelist_comment( 'override', $stackPtr ) ) { diff --git a/WordPress/Sniffs/WP/CapitalPDangitSniff.php b/WordPress/Sniffs/WP/CapitalPDangitSniff.php index 7ff8a392a1..ca42817f48 100644 --- a/WordPress/Sniffs/WP/CapitalPDangitSniff.php +++ b/WordPress/Sniffs/WP/CapitalPDangitSniff.php @@ -124,8 +124,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/WP/DeprecatedClassesSniff.php b/WordPress/Sniffs/WP/DeprecatedClassesSniff.php index 1860e299b0..1e46dcf320 100644 --- a/WordPress/Sniffs/WP/DeprecatedClassesSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedClassesSniff.php @@ -77,6 +77,8 @@ public function getGroups() { * @param array $group_name The name of the group which was matched. Will * always be 'deprecated_functions'. * @param string $matched_content The token content (class name) which was matched. + * + * @return void */ public function process_matched_token( $stackPtr, $group_name, $matched_content ) { diff --git a/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php b/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php index 2a770571ca..23c1d1d037 100644 --- a/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php @@ -1326,6 +1326,8 @@ public function getGroups() { * @param array $group_name The name of the group which was matched. Will * always be 'deprecated_functions'. * @param string $matched_content The token content (function name) which was matched. + * + * @return void */ public function process_matched_token( $stackPtr, $group_name, $matched_content ) { diff --git a/WordPress/Sniffs/WP/DeprecatedParametersSniff.php b/WordPress/Sniffs/WP/DeprecatedParametersSniff.php index aaafd66dee..30794b7aac 100644 --- a/WordPress/Sniffs/WP/DeprecatedParametersSniff.php +++ b/WordPress/Sniffs/WP/DeprecatedParametersSniff.php @@ -275,6 +275,8 @@ class DeprecatedParametersSniff extends AbstractFunctionParameterSniff { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. + * + * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { diff --git a/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php b/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php index 7559a5014c..7e47b042ea 100644 --- a/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php +++ b/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php @@ -82,8 +82,8 @@ class DiscouragedConstantsSniff extends AbstractFunctionParameterSniff { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { if ( isset( $this->target_functions[ strtolower( $this->tokens[ $stackPtr ]['content'] ) ] ) ) { @@ -103,6 +103,8 @@ public function process_token( $stackPtr ) { * @since 0.14.0 * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_arbitrary_tstring( $stackPtr ) { $content = $this->tokens[ $stackPtr ]['content']; @@ -189,6 +191,8 @@ public function process_arbitrary_tstring( $stackPtr ) { * @param array $group_name The name of the group which was matched. * @param string $matched_content The token content (function name) which was matched. * @param array $parameters Array with information about the parameters. + * + * @return void */ public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { $function_name = strtolower( $matched_content ); diff --git a/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php b/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php index ee70ee2956..965a28abe7 100644 --- a/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php +++ b/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php @@ -38,6 +38,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { $token = $this->tokens[ $stackPtr ]; diff --git a/WordPress/Sniffs/WP/I18nSniff.php b/WordPress/Sniffs/WP/I18nSniff.php index fe0cc62f6c..1967701d0b 100644 --- a/WordPress/Sniffs/WP/I18nSniff.php +++ b/WordPress/Sniffs/WP/I18nSniff.php @@ -158,6 +158,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stack_ptr The position of the current token in the stack. + * + * @return void */ public function process_token( $stack_ptr ) { $token = $this->tokens[ $stack_ptr ]; @@ -483,6 +485,7 @@ protected function check_argument_tokens( $context ) { * @param int $stack_ptr The position of the current token in the stack. * @param array $single_context Single context (@todo needs better description). * @param array $plural_context Plural context (@todo needs better description). + * @return void */ protected function compare_single_and_plural_arguments( $stack_ptr, $single_context, $plural_context ) { $single_content = $single_context['tokens'][0]['content']; @@ -516,6 +519,7 @@ protected function compare_single_and_plural_arguments( $stack_ptr, $single_cont * Check the string itself for problems. * * @param array $context Context (@todo needs better description). + * @return void */ protected function check_text( $context ) { $stack_ptr = $context['stack_ptr']; @@ -589,6 +593,7 @@ protected function check_text( $context ) { * * @param int $stack_ptr The position of the gettext call token in the stack. * @param array $args The function arguments. + * @return void */ protected function check_for_translator_comment( $stack_ptr, $args ) { foreach ( $args as $arg ) { diff --git a/WordPress/Sniffs/WP/PreparedSQLSniff.php b/WordPress/Sniffs/WP/PreparedSQLSniff.php index a654dca0b2..ff21f7a849 100644 --- a/WordPress/Sniffs/WP/PreparedSQLSniff.php +++ b/WordPress/Sniffs/WP/PreparedSQLSniff.php @@ -116,8 +116,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php index 62ea4c7933..e01df14e5c 100644 --- a/WordPress/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php @@ -101,8 +101,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php index b7a92c1d6c..75b420145f 100755 --- a/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php @@ -40,6 +40,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { diff --git a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index 3da54ead8b..2c70b77e62 100644 --- a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -108,6 +108,8 @@ public function register() { * Processes this test, when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. + * + * @return void */ public function process_token( $stackPtr ) { $this->spaces_before_closure_open_paren = (int) $this->spaces_before_closure_open_paren; diff --git a/WordPress/Sniffs/WhiteSpace/SemicolonSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/SemicolonSpacingSniff.php index f2a97be6db..147331862d 100644 --- a/WordPress/Sniffs/WhiteSpace/SemicolonSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/SemicolonSpacingSniff.php @@ -29,7 +29,7 @@ class SemicolonSpacingSniff extends PHPCS_Squiz_SemicolonSpacingSniff { * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return int + * @return void|int */ public function process( File $phpcsFile, $stackPtr ) { $tokens = $phpcsFile->getTokens(); diff --git a/WordPress/Sniffs/XSS/EscapeOutputSniff.php b/WordPress/Sniffs/XSS/EscapeOutputSniff.php index 9f01ca2452..8c0c76b4c5 100644 --- a/WordPress/Sniffs/XSS/EscapeOutputSniff.php +++ b/WordPress/Sniffs/XSS/EscapeOutputSniff.php @@ -189,8 +189,8 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * - * @return int Integer stack pointer to skip forward or void to continue - * normal file processing. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { @@ -455,6 +455,8 @@ public function process_token( $stackPtr ) { * Merge custom functions provided via a custom ruleset with the defaults, if we haven't already. * * @since 0.11.0 Split out from the `process()` method. + * + * @return void */ protected function mergeFunctionLists() { if ( $this->customEscapingFunctions !== $this->addedCustomFunctions['escape'] diff --git a/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php b/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php index bbcc4d890e..b13a53fc59 100644 --- a/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php +++ b/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php @@ -53,6 +53,8 @@ public function getCliValues( $testFile ) { * * @param string $testFile The name of the file being tested. * @param \PHP_CodeSniffer\Config $config The config data for the test run. + * + * @return void */ public function setCliValues( $testFile, $config ) { // Tab width setting is only needed for the tabbed file. diff --git a/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php b/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php index c538aab240..371aea87ae 100644 --- a/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php +++ b/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php @@ -56,6 +56,8 @@ public function getCliValues( $testFile ) { * * @param string $testFile The name of the file being tested. * @param \PHP_CodeSniffer\Config $config The config data for the test run. + * + * @return void */ public function setCliValues( $testFile, $config ) { // Tab width setting is only needed for the tabbed file. diff --git a/WordPress/Tests/WP/I18nUnitTest.php b/WordPress/Tests/WP/I18nUnitTest.php index fd677eb9e4..4eff21a0bc 100644 --- a/WordPress/Tests/WP/I18nUnitTest.php +++ b/WordPress/Tests/WP/I18nUnitTest.php @@ -47,6 +47,8 @@ public function getCliValues( $testFile ) { * * @param string $testFile The name of the file being tested. * @param \PHP_CodeSniffer\Config $config The config data for the test run. + * + * @return void */ public function setCliValues( $testFile, $config ) { // Test overruling the text domain from the command line for one test file. diff --git a/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php b/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php index e7865bac7c..8761423c85 100644 --- a/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php +++ b/WordPress/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php @@ -48,6 +48,8 @@ public function getCliValues( $testFile ) { * * @param string $testFile The name of the file being tested. * @param \PHP_CodeSniffer\Config $config The config data for the test run. + * + * @return void */ public function setCliValues( $testFile, $config ) { $config->tabWidth = $this->tab_width; diff --git a/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php b/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php index aebfebf723..57fcbbd428 100644 --- a/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php +++ b/WordPress/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php @@ -47,6 +47,8 @@ public function getCliValues( $testFile ) { * * @param string $testFile The name of the file being tested. * @param \PHP_CodeSniffer\Config $config The config data for the test run. + * + * @return void */ public function setCliValues( $testFile, $config ) { $config->tabWidth = $this->tab_width; From 8dc03a65d1e600b3dd8c1ad9e947abb2701140ff Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sun, 10 Dec 2017 16:18:39 -0500 Subject: [PATCH 11/14] Generalize sniff files to accomodate other checks on return types --- .../{NoReturnVoidSniff.php => FunctionCommentSniff.php} | 3 ++- .../{NoReturnVoidUnitTest.inc => FunctionCommentUnitTest.inc} | 0 .../{NoReturnVoidUnitTest.php => FunctionCommentUnitTest.php} | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename WordPress/Sniffs/Commenting/{NoReturnVoidSniff.php => FunctionCommentSniff.php} (95%) rename WordPress/Tests/Commenting/{NoReturnVoidUnitTest.inc => FunctionCommentUnitTest.inc} (100%) rename WordPress/Tests/Commenting/{NoReturnVoidUnitTest.php => FunctionCommentUnitTest.php} (100%) diff --git a/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php b/WordPress/Sniffs/Commenting/FunctionCommentSniff.php similarity index 95% rename from WordPress/Sniffs/Commenting/NoReturnVoidSniff.php rename to WordPress/Sniffs/Commenting/FunctionCommentSniff.php index dce5e98f72..a17c455459 100755 --- a/WordPress/Sniffs/Commenting/NoReturnVoidSniff.php +++ b/WordPress/Sniffs/Commenting/FunctionCommentSniff.php @@ -36,7 +36,8 @@ public function register() { * Processes this test when one of its tokens is encountered. * * @param int $stackPtr The position of the current token in the stack. - * @return int Integer stack pointer to skip the rest of the file. + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process_token( $stackPtr ) { $commentEnd = $this->phpcsFile->findPrevious( diff --git a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc b/WordPress/Tests/Commenting/FunctionCommentUnitTest.inc similarity index 100% rename from WordPress/Tests/Commenting/NoReturnVoidUnitTest.inc rename to WordPress/Tests/Commenting/FunctionCommentUnitTest.inc diff --git a/WordPress/Tests/Commenting/NoReturnVoidUnitTest.php b/WordPress/Tests/Commenting/FunctionCommentUnitTest.php similarity index 100% rename from WordPress/Tests/Commenting/NoReturnVoidUnitTest.php rename to WordPress/Tests/Commenting/FunctionCommentUnitTest.php From 7038b15a8206e09b3ae8f86f75a42d62e1aafa25 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sun, 10 Dec 2017 16:21:16 -0500 Subject: [PATCH 12/14] Move return checks into `process_return()` method --- WordPress-Docs/ruleset.xml | 2 +- .../Commenting/FunctionCommentSniff.php | 19 ++++++++++++++----- .../Commenting/FunctionCommentUnitTest.php | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/WordPress-Docs/ruleset.xml b/WordPress-Docs/ruleset.xml index ec6418d59a..00eed4a0ce 100644 --- a/WordPress-Docs/ruleset.xml +++ b/WordPress-Docs/ruleset.xml @@ -118,5 +118,5 @@ - + diff --git a/WordPress/Sniffs/Commenting/FunctionCommentSniff.php b/WordPress/Sniffs/Commenting/FunctionCommentSniff.php index a17c455459..72ec90c21c 100755 --- a/WordPress/Sniffs/Commenting/FunctionCommentSniff.php +++ b/WordPress/Sniffs/Commenting/FunctionCommentSniff.php @@ -13,15 +13,13 @@ use PHP_CodeSniffer_Tokens as Tokens; /** - * Disallows the 'void' return type. - * - * @link https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/#phpdoc-tags + * Validates function documentation. * * @package WPCS\WordPressCodingStandards * * @since 0.16.0 */ -class NoReturnVoidSniff extends Sniff { +class FunctionCommentSniff extends Sniff { /** * Registers the tokens that this sniff wants to listen for. @@ -37,7 +35,7 @@ public function register() { * * @param int $stackPtr The position of the current token in the stack. * @return int|void Integer stack pointer to skip forward or void to continue - * normal file processing. + * normal file processing. */ public function process_token( $stackPtr ) { $commentEnd = $this->phpcsFile->findPrevious( @@ -54,6 +52,17 @@ public function process_token( $stackPtr ) { $commentStart = $this->tokens[ $commentEnd ]['comment_opener']; + $this->process_return( $stackPtr, $commentStart ); + } + + /** + * Process this function's return comment. + * + * @param int $stackPtr The position of the current token in the stack. + * @param int $commentStart The position in the stack where the comment started. + * @return void + */ + protected function process_return( $stackPtr, $commentStart ) { $returnTag = null; foreach ( $this->tokens[ $commentStart ]['comment_tags'] as $tag ) { diff --git a/WordPress/Tests/Commenting/FunctionCommentUnitTest.php b/WordPress/Tests/Commenting/FunctionCommentUnitTest.php index 3bacd4b0f0..56b74ec3bf 100755 --- a/WordPress/Tests/Commenting/FunctionCommentUnitTest.php +++ b/WordPress/Tests/Commenting/FunctionCommentUnitTest.php @@ -18,7 +18,7 @@ * * @since 0.16.0 */ -class NoReturnVoidUnitTest extends AbstractSniffUnitTest { +class FunctionCommentUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. From 3f7caab778213892687a544f8f2e2fd166b7a7a2 Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sun, 10 Dec 2017 16:21:41 -0500 Subject: [PATCH 13/14] Allow `void` with other return types --- .../Commenting/FunctionCommentSniff.php | 26 +++---- .../Commenting/FunctionCommentUnitTest.inc | 74 +++++-------------- .../Commenting/FunctionCommentUnitTest.php | 6 -- 3 files changed, 30 insertions(+), 76 deletions(-) diff --git a/WordPress/Sniffs/Commenting/FunctionCommentSniff.php b/WordPress/Sniffs/Commenting/FunctionCommentSniff.php index 72ec90c21c..b8b6389724 100755 --- a/WordPress/Sniffs/Commenting/FunctionCommentSniff.php +++ b/WordPress/Sniffs/Commenting/FunctionCommentSniff.php @@ -94,22 +94,16 @@ protected function process_return( $stackPtr, $commentStart ) { $returnTypes = array_unique( explode( '|', $commentParts[1] ) ); - foreach ( $returnTypes as $type ) { - if ( 'void' === $type ) { - $error = '`@return void` should not be used.'; - - $recommendation = ( count( $returnTypes ) > 1 ) - ? 'Remove it from the list of return types instead' - : 'Omit the `@return` tag instead'; - - $this->phpcsFile->addError( - "$error $recommendation", - $returnTag, - 'ReturnVoidFound' - ); - - break; - } + /* + * Disallow `@return void`. + * See https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/#phpdoc-tags. + */ + if ( array( 'void' ) === $returnTypes ) { + $this->phpcsFile->addError( + '`@return void` should not be used. Omit the `@return` tag instead', + $returnTag, + 'NoReturnVoid' + ); } } diff --git a/WordPress/Tests/Commenting/FunctionCommentUnitTest.inc b/WordPress/Tests/Commenting/FunctionCommentUnitTest.inc index 930f10e32d..d90b88cd8f 100755 --- a/WordPress/Tests/Commenting/FunctionCommentUnitTest.inc +++ b/WordPress/Tests/Commenting/FunctionCommentUnitTest.inc @@ -1,85 +1,51 @@ 1, 14 => 1, - 23 => 1, - 32 => 1, - 41 => 1, - 50 => 1, - 59 => 1, - 68 => 1, ); } From 2eeaacb20357eb000b0734f8d7d57c7ef2cfb41e Mon Sep 17 00:00:00 2001 From: David Herrera Date: Sun, 10 Dec 2017 16:23:07 -0500 Subject: [PATCH 14/14] Exclude NoReturnVoid from internal ruleset --- bin/phpcs.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/phpcs.xml b/bin/phpcs.xml index c5c5b4cbe9..a20a5b0737 100644 --- a/bin/phpcs.xml +++ b/bin/phpcs.xml @@ -17,7 +17,10 @@ - + + + +