Skip to content

Commit 4198a6d

Browse files
jrfnlGaryJones
andcommitted
Security/EscapingVoidReturnFunctions: switch to using WPCS PrintingFunctionsTrait
Note: this does mean that the sniff will now also support a `public` `customPrintingFunctions` property which can be adjusted in a custom ruleset. Co-authored-by: Gary Jones <[email protected]>
1 parent d30a303 commit 4198a6d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

WordPressVIPMinimum/Sniffs/Security/EscapingVoidReturnFunctionsSniff.php

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

1111
use PHP_CodeSniffer\Util\Tokens;
12+
use WordPressCS\WordPress\Helpers\PrintingFunctionsTrait;
1213
use WordPressVIPMinimum\Sniffs\Sniff;
1314

1415
/**
1516
* Flag functions that don't return anything, yet are wrapped in an escaping function call.
1617
*
1718
* E.g. esc_html( _e( 'foo' ) );
1819
*
19-
* @package VIPCS\WordPressVIPMinimum
20+
* @package VIPCS\WordPressVIPMinimum
21+
*
22+
* @uses \WordPressCS\WordPress\Helpers\PrintingFunctionsTrait::$customPrintingFunctions
2023
*/
2124
class EscapingVoidReturnFunctionsSniff extends Sniff {
2225

26+
use PrintingFunctionsTrait;
27+
2328
/**
2429
* Returns an array of tokens this test wants to listen for.
2530
*
@@ -59,7 +64,7 @@ public function process_token( $stackPtr ) {
5964
return;
6065
}
6166

62-
if ( isset( $this->printingFunctions[ $this->tokens[ $next_token ]['content'] ] ) ) {
67+
if ( $this->is_printing_function( $this->tokens[ $next_token ]['content'] ) ) {
6368
$message = 'Attempting to escape `%s()` which is printing its output.';
6469
$data = [ $this->tokens[ $next_token ]['content'] ];
6570
$this->phpcsFile->addError( $message, $stackPtr, 'Found', $data );

0 commit comments

Comments
 (0)