Skip to content

Commit c028f32

Browse files
authored
Remove unused variables from a few sniffs (#2514)
* Remove unused variable passed as the third parameter to `preg_match()` This commit removes three instances where a variable was passed to `preg_match()` as the third parameter to fill it with the results of the search, but later it was not used. * EscapeOutput: remove unused variable `$end` This commit removes the unnecessary initialization of the variable `$end` at the beginning of the sniff code. Every single `case` statement of the `switch` that follows either re-initialize the variable with a different value or returns without using the variable.
1 parent 9f9726a commit c028f32

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

WordPress/Sniffs/Security/EscapeOutputSniff.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ public function getGroups() {
185185
*/
186186
public function process_token( $stackPtr ) {
187187
$start = ( $stackPtr + 1 );
188-
$end = $start;
189188

190189
switch ( $this->tokens[ $stackPtr ]['code'] ) {
191190
case \T_STRING:

WordPress/Sniffs/WP/I18nSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ private function check_for_translator_comment( $stackPtr, $matched_content, $par
873873
continue;
874874
}
875875

876-
if ( preg_match( self::SPRINTF_PLACEHOLDER_REGEX, $param_info['clean'], $placeholders ) === 1 ) {
876+
if ( preg_match( self::SPRINTF_PLACEHOLDER_REGEX, $param_info['clean'] ) === 1 ) {
877877
$needs_translators_comment = true;
878878
break;
879879
}
@@ -969,7 +969,7 @@ private function check_for_translator_comment( $stackPtr, $matched_content, $par
969969
* @return bool
970970
*/
971971
private function is_translators_comment( $content ) {
972-
if ( preg_match( '`^(?:(?://|/\*{1,2}) )?translators:`i', $content, $matches ) === 1 ) {
972+
if ( preg_match( '`^(?:(?://|/\*{1,2}) )?translators:`i', $content ) === 1 ) {
973973
return true;
974974
}
975975
return false;

WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ public function process_token( $stackPtr ) {
410410

411411
// Move past end comments.
412412
if ( $this->tokens[ $trailingContent ]['line'] === $this->tokens[ $scopeCloser ]['line'] ) {
413-
if ( preg_match( '`^//[ ]?end`i', $this->tokens[ $trailingContent ]['content'], $matches ) > 0 ) {
413+
if ( preg_match( '`^//[ ]?end`i', $this->tokens[ $trailingContent ]['content'] ) > 0 ) {
414414
$scopeCloser = $trailingContent;
415415
$trailingContent = $this->phpcsFile->findNext( \T_WHITESPACE, ( $trailingContent + 1 ), null, true );
416416
}

0 commit comments

Comments
 (0)