Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AbstractPatternSniff: prevent PHP notice
In a live coding situation, the token triggering the pattern being looked for could be at or near the end of the file. This could lead to a situation where the pattern could never match anyhow as there are not enough tokens left in the file to match against. In this situation, the sniff could trigger the following PHP error: ``` Increment on type bool has no effect, this will change in the next major version of PHP in path/to/phpcs/src/Sniffs/AbstractPatternSniff.php on line 627 ``` This commit prevents this error by bowing out early if there are not enough tokens in the file under scan to match the pattern. Tested via the `Squiz.Functions.FunctionDeclaration` sniff via which this issue was discovered.
- Loading branch information