Commit 5457312
committed
fix: handle missing semicolon in abstract function declarations
When processing malformed PHP code where an abstract function
declaration is missing both the semicolon and curly braces, the
FunctionDeclarationSniff would crash with "Undefined array key -1".
This occurred because findNext(T_SEMICOLON) returns false when no
semicolon is found, and the code attempted to access tokens[false - 1],
which evaluates to tokens[-1].
The fix checks if findNext() returns false and exits early, allowing
other sniffs to report the actual syntax error rather than crashing.
Fixes #39171 parent c6c65ca commit 5457312
File tree
1 file changed
+5
-0
lines changed- src/Standards/PEAR/Sniffs/Functions
1 file changed
+5
-0
lines changedLines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
130 | 135 | | |
131 | 136 | | |
132 | 137 | | |
| |||
0 commit comments