Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some undefined index notices in the WordPress.XSS.EscapeOutput sniff. #770

Merged
merged 1 commit into from
Jan 9, 2017

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jan 5, 2017

These would be thrown when live coding/running the sniffs on code with parse errors.

Quick fix for #248 (comment)

/cc @grappler

…sniff.

These would be thrown when live coding/running the sniffs on code with parse errors.
@jrfnl jrfnl added this to the 0.11.0 milestone Jan 5, 2017
@@ -208,6 +208,11 @@ public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {

if ( T_OPEN_PARENTHESIS === $this->tokens[ $i ]['code'] ) {

if ( ! isset( $this->tokens[ $i ]['parenthesis_closer'] ) ) {
// Live coding or parse error.
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually when PHPCS's core sniffs detect a parse error, they don't just skip out, they add a warning. At least they do in some cases. Should we consider doing the same here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO that's what the Generic.PHP.Syntax sniff is for (included in extra)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that makes sense. So I guess for consistency we should change the one place we give an error for syntax issues. But that can be a separate PR, I guess.

$i = $this->tokens[ $function_opener ]['parenthesis_closer'];
} else {
// Live coding or parse error.
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Member

@grappler grappler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the PR and confirm it works. 😄

JDGrimes added a commit that referenced this pull request Jan 5, 2017
GaryJones pushed a commit that referenced this pull request Jan 6, 2017
@jrfnl jrfnl merged commit 1cc17af into develop Jan 9, 2017
@jrfnl jrfnl deleted the feature/issue-248-undefined-notices branch January 9, 2017 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants