You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PEAR.Functions.FunctionDeclaration gets confused by multi-line block comments inside a function's argument list #1368
Squiz.Functions.MultiLineFunctionDeclaration gets confused by multi-line block comments inside a function's argument list.
Code sample
<?phpfunctionfoo(
/* ??? */
) {
}
Custom ruleset
N/A
To reproduce
Steps to reproduce the behavior:
Create a file called test.php with the code sample above.
Run phpcbf --sniffs=Squiz.Functions.MultiLineFunctionDeclaration test.php
See error message displayed
PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE FIXED REMAINING
----------------------------------------------------------------------
/tmp/test/test.php FAILED TO FIX
----------------------------------------------------------------------
A TOTAL OF 0 ERRORS WERE FIXED IN 1 FILE
----------------------------------------------------------------------
PHPCBF FAILED TO FIX 1 FILE
----------------------------------------------------------------------
Run phpcs --sniffs=Squiz.Functions.MultiLineFunctionDeclaration test.php
See odd sniff results displayed
FILE: /tmp/test/test.php
-------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------
5 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 0
6 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 0
-------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------
This is despite the lines already being indented. Using spaces rather than tabs does not help.
Expected behavior
phpcbf does not fail to fix. phpcs gives errors that make sense, or doesn't give errors at all.
Versions (please complete the following information)
changed the title [-]`Squiz.Functions.MultiLineFunctionDeclaration` gets confused by multi-line block comments inside a function's argument list[/-][+]`PEAR.Functions.FunctionDeclaration` gets confused by multi-line block comments inside a function's argument list[/+]on Mar 1, 2026
@anomiex Thank you for reporting this. I can confirm this issue as reproducible.
The problem wasn't actually in the Squiz.Functions.MultiLineFunctionDeclaration sniff, but rather in the underlying PEAR.Functions.FunctionDeclaration sniff, which the MultiLineFunctionDeclaration sniff extends.
Fixing it in the PEAR sniff will fix this for the Squiz sniff too.
The issue is caused by subsequent tokens in a multi-line block comment including the indentation in the T_COMMENT token and the sniff not taking the possibility for block comments within a function declaration into account.
Activity
Move block comments out of function parameter lists in DAL3.Helpers
CRM: Fix code style formatting throughout codebase (#46809)
CRM: Fix code style formatting throughout codebase (#46809)
CRM: Fix code style formatting throughout codebase (#46809)
[-]`Squiz.Functions.MultiLineFunctionDeclaration` gets confused by multi-line block comments inside a function's argument list[/-][+]`PEAR.Functions.FunctionDeclaration` gets confused by multi-line block comments inside a function's argument list[/+]jrfnl commentedon Mar 1, 2026
@anomiex Thank you for reporting this. I can confirm this issue as reproducible.
The problem wasn't actually in the
Squiz.Functions.MultiLineFunctionDeclarationsniff, but rather in the underlyingPEAR.Functions.FunctionDeclarationsniff, which theMultiLineFunctionDeclarationsniff extends.Fixing it in the PEAR sniff will fix this for the Squiz sniff too.
The issue is caused by subsequent tokens in a multi-line block comment including the indentation in the
T_COMMENTtoken and the sniff not taking the possibility for block comments within a function declaration into account.jrfnl commentedon Mar 1, 2026
PR #1378 should fix this. Testing/review appreciated.