Skip to content

Commit 0b2d95d

Browse files
committed
WhiteSpace/DisallowSpace/TabIndent: bug fix - inspect complete file
Both these sniffs include `T_INLINE_HTML` in the `$checkTokens` array, but would only start checking the file **after** the first PHP open tag, so if a file - such as a view - would start with inline HTML and only have the first PHP open tag on line 5, the first 4 lines would not be inspected, nor fixed for tabs vs spaces. I have not added unit tests for this as it would require to either renumber all the unit tests òr to add a second unit test file for both sniffs. If so desired, I'd be happy to make those changes, but it seemed a bit over the top for such a small change.
1 parent 935c8b5 commit 0b2d95d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr)
7575
];
7676

7777
$tokens = $phpcsFile->getTokens();
78-
for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
78+
for ($i = 0; $i < $phpcsFile->numTokens; $i++) {
7979
if ($tokens[$i]['column'] !== 1 || isset($checkTokens[$tokens[$i]['code']]) === false) {
8080
continue;
8181
}

src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function process(File $phpcsFile, $stackPtr)
7777
T_DOC_COMMENT_STRING => true,
7878
];
7979

80-
for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
80+
for ($i = 0; $i < $phpcsFile->numTokens; $i++) {
8181
if (isset($checkTokens[$tokens[$i]['code']]) === false) {
8282
continue;
8383
}

0 commit comments

Comments
 (0)