Skip to content

Commit 05c0ee4

Browse files
authored
Merge pull request #1788 from WordPress/feature/escapeoutput-minor-cleanup
EscapeOutput: use Sniff::$safe_casts
2 parents 30aef1d + 3d80421 commit 05c0ee4

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

WordPress/Sniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ abstract class Sniff implements PHPCS_Sniff {
372372
\T_INT_CAST => true,
373373
\T_DOUBLE_CAST => true,
374374
\T_BOOL_CAST => true,
375+
\T_UNSET_CAST => true,
375376
);
376377

377378
/**

WordPress/Sniffs/Security/EscapeOutputSniff.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,6 @@ class EscapeOutputSniff extends Sniff {
124124
'PHP_DEBUG' => true, // Integer.
125125
);
126126

127-
/**
128-
* List of names of the cast tokens which can be considered as a safe escaping method.
129-
*
130-
* @since 0.12.0
131-
*
132-
* @var array
133-
*/
134-
private $safe_cast_tokens = array(
135-
'T_INT_CAST' => true, // (int)
136-
'T_DOUBLE_CAST' => true, // (float)
137-
'T_BOOL_CAST' => true, // (bool)
138-
'T_UNSET_CAST' => true, // (unset)
139-
);
140-
141127
/**
142128
* List of tokens which can be considered as a safe when directly part of the output.
143129
*
@@ -367,7 +353,7 @@ public function process_token( $stackPtr ) {
367353
$watch = false;
368354

369355
// Allow int/double/bool casted variables.
370-
if ( isset( $this->safe_cast_tokens[ $this->tokens[ $i ]['type'] ] ) ) {
356+
if ( isset( $this->safe_casts[ $this->tokens[ $i ]['code'] ] ) ) {
371357
$in_cast = true;
372358
continue;
373359
}

0 commit comments

Comments
 (0)