Php_codesniffer: File::findEndOfStatement() not working when passed a scope opener

Created on 24 Jan 2018  路  2Comments  路  Source: squizlabs/PHP_CodeSniffer

while(true) {}
$v = 1;

When $stackPtr is set on while:

$end = $phpcsFile->findEndOfStatement($stackPtr);

then $end is the ; not the }.

Do you think it's a bug or desired behaviour?

Bug

All 2 comments

That's not desired behaviour, and my first instinct is to say "the end of the statement for scope blocks is always the scope closer" but I'd need to look into it before making a change like that. So I'll put it on 3.3.0 milestone instead of a straight bug-fix release.

I've fixed this up by doing when I described in my previous comment. Also added some unit tests. Thanks a lot for reporting this.

Was this page helpful?
0 / 5 - 0 ratings