.... to allow for adding additional test case files.
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.
Suggested changelog entry
AbstractPatternSniff: bug fix for potential PHP notice during live coding
Related issues/external references
Loosely related to #152 as this issue was discovered when creating an update for the fixer conflict list.
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
Description
Squiz/FunctionDeclaration: rename test case file
.... to allow for adding additional test case files.
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:
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.Suggested changelog entry
AbstractPatternSniff: bug fix for potential PHP notice during live coding
Related issues/external references
Loosely related to #152 as this issue was discovered when creating an update for the fixer conflict list.
Types of changes