Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PEAR/Functions/FunctionDeclaration: add extra defensive coding
When the sniff is run during live coding, the sniff could encounter a situation where a function declaration does not have a scope opener, not a function body. In that case, the "SpaceBeforeSemicolon" check would try to find a semi-colon, presuming the function is an abstract method or interface method, but would not find one, which would result in the `if ($tokens[($end - 1)]['content'] === $phpcsFile->eolChar)` condition throwing a _"Undefined array key -1"_ notice. Fixed now. Includes test safeguarding the fix. Note: this fix will, by extension, fix this same error for the `PSR2.Methods.FunctionCallSignature` sniff and the `Squiz.Functions.MultiLineFunctionDeclaration` sniff. :point_right: this commit will be easier to review while ignoring whitespace changes.
- Loading branch information