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?
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.