Skip to content
New issue

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

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

Already on GitHub? # to your account

Various sniffs: simplify skipping the rest of the file #385

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Nov 8, 2024

This commit updates various sniffs to use return $phpcsFile->numTokens instead of return ($phpcsFile->numTokens + 1).

If a sniff file contains 50 tokens, the last $stackPtr will be 49, so returning 50 will already get us passed the end of the token stack and the + 1 is redundant.

Includes changing a plain return statements to return $phpcsFile->numTokens for efficiency.

This commit updates various sniffs to use `return $phpcsFile->numTokens` instead of `return ($phpcsFile->numTokens + 1)`.

If a sniff file contains 50 tokens, the last `$stackPtr` will be 49, so returning `50` will already get us passed the end of the token stack and the `+ 1` is redundant.

Includes changing a plain `return` statements to `return $phpcsFile->numTokens` for efficiency.
@coveralls
Copy link

Coverage Status

coverage: 99.248%. remained the same
when pulling 47c73a8 on feature/minor-simplifications
into 4673027 on develop.

@jrfnl jrfnl merged commit 4157c4c into develop Nov 8, 2024
30 checks passed
@jrfnl jrfnl deleted the feature/minor-simplifications branch November 8, 2024 12:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants