Skip to content

Commit

Permalink
WhiteSpace/DisallowSpace/TabIndent: bug fix - inspect complete file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrfnl committed Nov 26, 2017
1 parent 935c8b5 commit 0b2d95d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr)
];

$tokens = $phpcsFile->getTokens();
for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
for ($i = 0; $i < $phpcsFile->numTokens; $i++) {
if ($tokens[$i]['column'] !== 1 || isset($checkTokens[$tokens[$i]['code']]) === false) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function process(File $phpcsFile, $stackPtr)
T_DOC_COMMENT_STRING => true,
];

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

0 comments on commit 0b2d95d

Please sign in to comment.