Skip to content

Commit 0535c1a

Browse files
authored
Merge pull request #1677 from WordPress-Coding-Standards/feature/1541-validatedsanitizedinput-improve-error-messages
ValidatedSanitizedInput: make the error messages more informative
2 parents 33b55fe + b4fb6ba commit 0535c1a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

WordPress/Sniffs/Security/ValidatedSanitizedInputSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ function ( $symbol ) {
129129
return;
130130
}
131131

132-
$error_data = array( $this->tokens[ $stackPtr ]['content'] );
132+
$error_data = array( $this->tokens[ $stackPtr ]['content'] . '[' . implode( '][', $array_keys ) . ']' );
133133

134134
// Check for validation first.
135135
if ( ! $this->is_validated( $stackPtr, $array_keys, $this->check_validation_in_scope_only ) ) {
136136
$this->phpcsFile->addError(
137-
'Detected usage of a non-validated input variable: %s',
137+
'Detected usage of a possibly undefined superglobal array index: %s. Use isset() or empty() to check the index exists before using it',
138138
$stackPtr,
139139
'InputNotValidated',
140140
$error_data

0 commit comments

Comments
 (0)