Skip to content

Commit 5f01f59

Browse files
committed
Update sniff to include static method calls
Still a WIP
1 parent 640d886 commit 5f01f59

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

Diff for: WordPress/Sniffs/Security/EscapeOutputSniff.php

+8-11
Original file line numberDiff line numberDiff line change
@@ -614,17 +614,6 @@ protected function check_code_is_escaped( $start, $end ) {
614614
) {
615615
$i = $class_keyword;
616616
continue;
617-
} else { // Static method call. Current token should be flagged and the rest should be skipped.
618-
$content = $this->tokens[ $i ]['content'];
619-
620-
$this->phpcsFile->addError(
621-
"All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '%s'.",
622-
$i,
623-
'OutputNotEscaped',
624-
array( $content )
625-
);
626-
627-
break;
628617
}
629618
}
630619
}
@@ -748,6 +737,14 @@ protected function check_code_is_escaped( $start, $end ) {
748737

749738
$content = $functionName;
750739

740+
// Check if it's static method call.
741+
$double_colon = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), $end, true );
742+
if ( false !== $double_colon
743+
&& \T_DOUBLE_COLON === $this->tokens[ $double_colon ]['code']
744+
) {
745+
// Set the pointer to the end of the method.
746+
$i = $this->phpcsFile->findNext( \T_CLOSE_PARENTHESIS, $i, $end );
747+
}
751748
} else {
752749
$content = $this->tokens[ $i ]['content'];
753750
$ptr = $i;

0 commit comments

Comments
 (0)