Skip to content
This repository was archived by the owner on Nov 5, 2022. It is now read-only.

Commit 028a092

Browse files
committed
Fixed clash with vertical spacing
1 parent f0e886c commit 028a092

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

CodeIgniter4/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ public function process(File $phpcsFile, $stackPtr)
157157
}//end if
158158
} else {
159159
if ($found !== (int) $this->allowedLines) {
160-
if ($found < 0) {
161-
$found = 0;
162-
}
163-
164160
if ($this->allowedLines === 1) {
165161
$plural = '';
166162
} else {
@@ -176,21 +172,16 @@ public function process(File $phpcsFile, $stackPtr)
176172
$fix = $phpcsFile->addFixableError($error, $closeBrace, 'SpacingBeforeClose', $data);
177173

178174
if ($fix === true) {
179-
if ($found > 1) {
175+
if ($found > $this->allowedLines) {
180176
$phpcsFile->fixer->beginChangeset();
181-
for ($i = ($prevContent + 1); $i < ($closeBrace - 1); $i++) {
177+
for ($i = ($prevContent + 1); $i < ($closeBrace); $i++) {
182178
$phpcsFile->fixer->replaceToken($i, '');
183179
}
184180

185-
$phpcsFile->fixer->replaceToken($i, $phpcsFile->eolChar);
181+
$phpcsFile->fixer->replaceToken(($closeBrace - 1), $phpcsFile->eolChar);
186182
$phpcsFile->fixer->endChangeset();
187183
} else {
188-
// Try to maintain indentation.
189-
if ($tokens[($closeBrace - 1)]['code'] === T_WHITESPACE) {
190-
$phpcsFile->fixer->addNewlineBefore($closeBrace - 1);
191-
} else {
192-
$phpcsFile->fixer->addNewlineBefore($closeBrace);
193-
}
184+
$phpcsFile->fixer->addNewlineBefore($closeBrace);
194185
}
195186
}
196187
}//end if

0 commit comments

Comments
 (0)