Describe the bug
Squiz.Functions.MultiLineFunctionDeclaration gets confused by multi-line block comments inside a function's argument list.
Code sample
<?php
function foo(
/*
???
*/
) {
}
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)
|
|
| Operating System |
Linux (Debian sid) |
| PHP version |
8.4.16 |
| PHP_CodeSniffer version |
4.0.1, 4.x-dev 00cef30 |
| Standard |
Squiz |
| Install type |
Composer local |
Additional context
Running with -vvv indicates that phpcbf loops adding more and more indentation to the lines until hitting its maximum number of loops.
Please confirm
Describe the bug
Squiz.Functions.MultiLineFunctionDeclarationgets confused by multi-line block comments inside a function's argument list.Code sample
Custom ruleset
N/A
To reproduce
Steps to reproduce the behavior:
test.phpwith the code sample above.phpcbf --sniffs=Squiz.Functions.MultiLineFunctionDeclaration test.phpphpcs --sniffs=Squiz.Functions.MultiLineFunctionDeclaration test.phpExpected behavior
phpcbfdoes not fail to fix.phpcsgives errors that make sense, or doesn't give errors at all.Versions (please complete the following information)
Additional context
Running with
-vvvindicates thatphpcbfloops adding more and more indentation to the lines until hitting its maximum number of loops.Please confirm
4.xbranch of PHP_CodeSniffer.