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
Seems PEAR.Functions.FunctionCallSignature.Indent sniff and fix works incorrectly with some nested structures.
The problem appears when there is indentation issue together with another issue, like PEAR.WhiteSpace.ScopeIndent.Incorrect.
After running phpcbf wrong number of indentation character (space) is not reported anymore.
The problem does not appear when correctly formatted and correct code is processed by phpcbf, nor does it mess up the good code.
Create a file called test.php with the code sample above...
Run phpcs test.php ...
See error message displayed
Run phpcbf test.php
Check indentation
phpcs test.php no longer reports indentation error.
PHPCS output here
-------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 6 LINES
-------------------------------------------------------------------------------------------------------------------------------------------------------
2 | ERROR | [ ] Missing file doc comment (PEAR.Commenting.FileComment.Missing)
2 | ERROR | [ ] Missing doc comment for function store() (PEAR.Commenting.FunctionComment.Missing)
4 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 2 (PEAR.WhiteSpace.ScopeIndent.Incorrect)
4 | ERROR | [x] Opening statement of multi-line function call not indented correctly; expected 0 spaces but found 2
| | (PEAR.Functions.FunctionCallSignature.OpeningIndent)
4 | ERROR | [x] Opening parenthesis of a multi-line function call must be the last content on the line
| | (PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket)
5 | ERROR | [x] Multi-line function call not indented correctly; expected 6 spaces but found 4 (PEAR.Functions.FunctionCallSignature.Indent)
9 | ERROR | [x] Multi-line function call not indented correctly; expected 6 spaces but found 4 (PEAR.Functions.FunctionCallSignature.Indent)
10 | ERROR | [x] Multi-line function call not indented correctly; expected 6 spaces but found 4 (PEAR.Functions.FunctionCallSignature.Indent)
11 | ERROR | [x] Multi-line function call not indented correctly; expected 2 spaces but found 4 (PEAR.Functions.FunctionCallSignature.Indent)
-------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 91ms; Memory: 6MB
Expected behavior
Phpcbf: follow standard while fixing.
Phpcs: catch wrong indentation.
Versions (please complete the following information)
My guess is sniffer would need recursive processing of multi line function calls. Or from inside to outside.
I tried to look into it, but it was too much...
Describe the bug
Seems PEAR.Functions.FunctionCallSignature.Indent sniff and fix works incorrectly with some nested structures.
The problem appears when there is indentation issue together with another issue, like PEAR.WhiteSpace.ScopeIndent.Incorrect.
After running phpcbf wrong number of indentation character (space) is not reported anymore.
The problem does not appear when correctly formatted and correct code is processed by phpcbf, nor does it mess up the good code.
Sample code
Phpcbf formatting
Another Phpcs wrong indent not caught:
Sample from PEAR standard
From: https://pear.php.net/manual/en/standards.funcalls.php
Custom ruleset
No custom ruleset
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcs test.php ...
phpcbf test.php
Expected behavior
Phpcbf: follow standard while fixing.
Phpcs: catch wrong indentation.
Versions (please complete the following information)
Please confirm
master
branch of PHP_CodeSniffer.Thank you!
The text was updated successfully, but these errors were encountered: