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
I get false positive Generic.WhiteSpace.ScopeIndent.IncorrectExact
when an foreach has an heredoc in it.
Code sample
<?php
(static function () {
foreach ([] as $a) {
echo '.';
if ($a) {
echo '.';
}
}
foreach (
[
<<<EOL
TEST
EOL,
] as $b
) {
echo '.';
if ($b) {
echo '.';
}
}
})();
Custom ruleset
using a psr12 ruleset, but get the same error but for PEAR.WhiteSpace.ScopeIndent.IncorrectExact
when running with a fresh clone of this repo.
To reproduce
Steps to reproduce the behavior:
Create a file called test.php with the code sample above...
Run phpcs -s --sniffs="PEAR.WhiteSpace.ScopeIndent" test.php ...
See error message displayed
---------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------------------------
19 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
| | (PEAR.WhiteSpace.ScopeIndent.IncorrectExact)
21 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
| | (PEAR.WhiteSpace.ScopeIndent.IncorrectExact)
---------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------
or with my config, i get Generic instead of PEAR:
------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------
19 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
| | (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
21 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
| | (Generic.WhiteSpace.ScopeIndent.IncorrectExact)
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------
Expected behavior
I expect both row 18 and 19 if ($b) { should have the same indentation, 8 spaces.
So instead of the warning, it should expect 8 and found 8, and therefor not show the warning.
Versions (please complete the following information)
PHP_CodeSniffer version 3.8.0 (stable) by Squiz and PHPCSStandards
Describe the bug
I get false positive
Generic.WhiteSpace.ScopeIndent.IncorrectExact
when an foreach has an heredoc in it.
Code sample
Custom ruleset
using a psr12 ruleset, but get the same error but for
PEAR.WhiteSpace.ScopeIndent.IncorrectExact
when running with a fresh clone of this repo.
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcs -s --sniffs="PEAR.WhiteSpace.ScopeIndent" test.php ...
or with my config, i get Generic instead of PEAR:
Expected behavior
I expect both row 18 and 19
if ($b) {
should have the same indentation, 8 spaces.So instead of the warning, it should
expect 8 and found 8
, and therefor not show the warning.Versions (please complete the following information)
PHP_CodeSniffer version 3.8.0 (stable) by Squiz and PHPCSStandards
Additional context
Workaround: move the heredoc before the foreach.
Please confirm:
master
branch of PHP_CodeSniffer.The text was updated successfully, but these errors were encountered: