-
-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
Describe the bug
If --tab-width is set, the fixer for Generic.Strings.UnnecessaryHeredoc incorrectly converts tabs into spaces in lines edited in the heredoc.
Code sample
Note this file must be indented using tabs, not spaces.
<?php
$var = <<<EOF
Normal line
Test \$escaped var
Normal line
EOF;Custom ruleset
N/A
To reproduce
Steps to reproduce the behavior:
- Create a file called
test.phpwith the code sample above. - Run
phpcbf -s --tab-width=8 --standard=Generic --sniffs=Generic.Strings.UnnecessaryHeredoc test.php - Examine the file.
Expected behavior
File content is
<?php
$var = <<<'EOF'
Normal line
Test $escaped var
Normal line
EOF;Actual behavior
File content is
<?php
$var = <<<'EOF'
Normal line
Test $escaped var
Normal line
EOF;i.e. the line "Test $escaped var" is indented with 8 spaces rather than one tab.
Versions (please complete the following information)
| Operating System | Debian unstable |
| PHP version | 8.4.11 |
| PHP_CodeSniffer version | 4.x-dev 4067971. Also reproduces with 3.13.5, 3.13.3, and 3.13.2. |
| Standard | Generic |
| Install type | Composer local |
Additional context
Add any other context about the problem here.
Please confirm
- I have searched the issue list and am not opening a duplicate issue.
- I have read the Contribution Guidelines and this is not a support question.
- I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
- I have verified the issue still exists in the
4.xbranch of PHP_CodeSniffer.