diff --git a/package.xml b/package.xml index 8efb23c5b6..4336e79855 100644 --- a/package.xml +++ b/package.xml @@ -61,6 +61,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> - Fixed an issue that could occurr when checking files on network drives, such as with WSL2 on Windows 10 -- This works around a long-standing PHP bug with is_readable() -- Thanks to Michael S for the patch + - Fixed bug #2913 : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional - Fixed bug #3157 : PSR2.ControlStructures.SwitchDeclaration.BreakIndent false positive when case keyword is not indented diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php index 1537d46c85..0ad9c59b48 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -337,7 +337,14 @@ public function process(File $phpcsFile, $stackPtr) echo "\t* open tag is inside condition; using open tag *".PHP_EOL; } - $checkIndent = ($tokens[$lastOpenTag]['column'] - 1); + $first = $phpcsFile->findFirstOnLine([T_WHITESPACE, T_INLINE_HTML], $lastOpenTag, true); + if ($this->debug === true) { + $line = $tokens[$first]['line']; + $type = $tokens[$first]['type']; + echo "\t* first token on line $line is $first ($type) *".PHP_EOL; + } + + $checkIndent = ($tokens[$first]['column'] - 1); if (isset($adjustments[$condition]) === true) { $checkIndent += $adjustments[$condition]; } diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc index 5fc112f521..d0bf0873c3 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc @@ -1462,6 +1462,12 @@ echo $string?->append('foo') ?->outputUsing(); // phpcs:set Generic.WhiteSpace.ScopeIndent exact false +if (true) { + ?> diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed index 055be55d83..a5c18bdb62 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed @@ -1462,6 +1462,12 @@ echo $string?->append('foo') ?->outputUsing(); // phpcs:set Generic.WhiteSpace.ScopeIndent exact false +if (true) { + ?> diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc index 4bb836ce78..1c7ff38a2d 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc @@ -1462,6 +1462,12 @@ echo $string?->append('foo') ?->outputUsing(); // phpcs:set Generic.WhiteSpace.ScopeIndent exact false +if (true) { + ?> diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed index c923c9a522..eb159fb7af 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed @@ -1462,6 +1462,12 @@ echo $string?->append('foo') ?->outputUsing(); // phpcs:set Generic.WhiteSpace.ScopeIndent exact false +if (true) { + ?> diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php index 3fd5f9f0f0..aeb41b73c5 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -178,10 +178,10 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc') 1340 => 1, 1342 => 1, 1345 => 1, - 1473 => 1, - 1474 => 1, - 1475 => 1, - 1476 => 1, + 1479 => 1, + 1480 => 1, + 1481 => 1, + 1482 => 1, ]; }//end getErrorList()