Skip to content

Commit d2dbefd

Browse files
committed
Sniff::strip_quotes(): use PHPCSUtils version
1 parent 48c05e2 commit d2dbefd

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

WordPressVIPMinimum/Sniffs/Functions/DynamicCallsSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace WordPressVIPMinimum\Sniffs\Functions;
99

1010
use PHP_CodeSniffer\Util\Tokens;
11+
use PHPCSUtils\Utils\TextStrings;
1112
use WordPressVIPMinimum\Sniffs\Sniff;
1213

1314
/**
@@ -139,7 +140,7 @@ private function collect_variables() {
139140
* If we reached the end of the loop and the $value_ptr was set, we know for sure
140141
* this was a plain text string variable assignment.
141142
*/
142-
$current_var_value = $this->strip_quotes( $this->tokens[ $value_ptr ]['content'] );
143+
$current_var_value = TextStrings::stripQuotes( $this->tokens[ $value_ptr ]['content'] );
143144

144145
if ( isset( $this->disallowed_functions[ $current_var_value ] ) === false ) {
145146
// Text string is not one of the ones we're looking for.

WordPressVIPMinimum/Sniffs/Performance/LowExpiryCacheTimeSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace WordPressVIPMinimum\Sniffs\Performance;
99

1010
use PHP_CodeSniffer\Util\Tokens;
11+
use PHPCSUtils\Utils\TextStrings;
1112
use WordPressCS\WordPress\AbstractFunctionParameterSniff;
1213

1314
/**
@@ -147,7 +148,7 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p
147148
}
148149

149150
if ( $this->tokens[ $i ]['code'] === T_CONSTANT_ENCAPSED_STRING ) {
150-
$content = $this->strip_quotes( $this->tokens[ $i ]['content'] );
151+
$content = TextStrings::stripQuotes( $this->tokens[ $i ]['content'] );
151152
if ( is_numeric( $content ) === true ) {
152153
$tokensAsString .= $content;
153154
continue;

WordPressVIPMinimum/Sniffs/Security/ProperEscapingFunctionSniff.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
namespace WordPressVIPMinimum\Sniffs\Security;
1010

11-
use WordPressVIPMinimum\Sniffs\Sniff;
1211
use PHP_CodeSniffer\Util\Tokens;
12+
use PHPCSUtils\Utils\TextStrings;
13+
use WordPressVIPMinimum\Sniffs\Sniff;
1314

1415
/**
1516
* Checks whether proper escaping function is used.
@@ -195,7 +196,7 @@ public function process_token( $stackPtr ) {
195196

196197
$content = $this->tokens[ $html ]['content'];
197198
if ( isset( Tokens::$stringTokens[ $this->tokens[ $html ]['code'] ] ) === true ) {
198-
$content = Sniff::strip_quotes( $content );
199+
$content = TextStrings::stripQuotes( $content );
199200
}
200201

201202
$escaping_type = $this->escaping_functions[ $function_name ];

WordPressVIPMinimum/Sniffs/Security/UnderscorejsSniff.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace WordPressVIPMinimum\Sniffs\Security;
1010

1111
use PHP_CodeSniffer\Util\Tokens;
12+
use PHPCSUtils\Utils\TextStrings;
1213
use WordPressVIPMinimum\Sniffs\Sniff;
1314

1415
/**
@@ -72,7 +73,7 @@ public function process_token( $stackPtr ) {
7273
/*
7374
* Ignore Gruntfile.js files as they are configuration, not code.
7475
*/
75-
$file_name = $this->strip_quotes( $this->phpcsFile->getFileName() );
76+
$file_name = TextStrings::stripQuotes( $this->phpcsFile->getFileName() );
7677
$file_name = strtolower( basename( $file_name ) );
7778

7879
if ( $file_name === 'gruntfile.js' ) {
@@ -120,7 +121,7 @@ public function process_token( $stackPtr ) {
120121
return;
121122
}
122123

123-
$content = $this->strip_quotes( $this->tokens[ $stackPtr ]['content'] );
124+
$content = TextStrings::stripQuotes( $this->tokens[ $stackPtr ]['content'] );
124125

125126
$match_count = preg_match_all( self::UNESCAPED_INTERPOLATE_REGEX, $content, $matches );
126127
if ( $match_count > 0 ) {

WordPressVIPMinimum/Sniffs/UserExperience/AdminBarRemovalSniff.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace WordPressVIPMinimum\Sniffs\UserExperience;
1111

12+
use PHPCSUtils\Utils\TextStrings;
1213
use WordPressCS\WordPress\AbstractFunctionParameterSniff;
1314
use PHP_CodeSniffer\Util\Tokens;
1415

@@ -207,13 +208,13 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p
207208
break;
208209

209210
case 'add_filter':
210-
$filter_name = $this->strip_quotes( $parameters[1]['raw'] );
211+
$filter_name = TextStrings::stripQuotes( $parameters[1]['raw'] );
211212
if ( $filter_name !== 'show_admin_bar' ) {
212213
break;
213214
}
214215

215216
$error = true;
216-
if ( $this->remove_only === true && isset( $parameters[2]['raw'] ) && $this->strip_quotes( $parameters[2]['raw'] ) === '__return_true' ) {
217+
if ( $this->remove_only === true && isset( $parameters[2]['raw'] ) && TextStrings::stripQuotes( $parameters[2]['raw'] ) === '__return_true' ) {
217218
$error = false;
218219
}
219220
break;

0 commit comments

Comments
 (0)