@@ -26,10 +26,6 @@ public function register(): array {
2626 public function process (File $ phpcsFile , $ stackPtr ) {
2727 $ tokens = $ phpcsFile ->getTokens ();
2828
29- if ($ tokens [$ stackPtr ]['code ' ] === T_ELSEIF && $ this ->isNotLastCondition ($ phpcsFile , $ stackPtr )) {
30- return ;
31- }
32-
3329 $ prevScopeEndIndex = $ phpcsFile ->findPrevious (T_WHITESPACE , $ stackPtr - 1 , null , true );
3430 if (!$ prevScopeEndIndex || empty ($ tokens [$ prevScopeEndIndex ]['scope_opener ' ])) {
3531 return ;
@@ -129,31 +125,6 @@ public function process(File $phpcsFile, $stackPtr) {
129125 $ phpcsFile ->fixer ->endChangeset ();
130126 }
131127
132- /**
133- * @param \PHP_CodeSniffer\Files\File $phpcsFile
134- * @param int $stackPtr
135- *
136- * @return bool
137- */
138- protected function isNotLastCondition (File $ phpcsFile , int $ stackPtr ): bool {
139- $ tokens = $ phpcsFile ->getTokens ();
140-
141- // Abort if not known
142- if (empty ($ tokens [$ stackPtr ]['scope_closer ' ])) {
143- return true ;
144- }
145-
146- $ nextScopeEndIndex = $ tokens [$ stackPtr ]['scope_closer ' ];
147-
148- $ nextConditionStartIndex = $ phpcsFile ->findNext (T_WHITESPACE , $ nextScopeEndIndex + 1 , null , true );
149-
150- if (in_array ($ tokens [$ nextConditionStartIndex ]['code ' ], [T_ELSEIF , T_ELSE ], true )) {
151- return true ;
152- }
153-
154- return false ;
155- }
156-
157128 /**
158129 * @param \PHP_CodeSniffer\Files\File $phpcsFile
159130 * @param int $stackPtr
@@ -166,10 +137,7 @@ protected function fixElseIfToIf(File $phpcsFile, int $stackPtr): void {
166137 $ phpcsFile ->fixer ->beginChangeset ();
167138
168139 $ prevIndex = $ phpcsFile ->findPrevious (T_WHITESPACE , $ stackPtr - 1 , null , true );
169- $ indentationLevel = $ tokens [$ prevIndex ]['column ' ] - 1 ;
170- $ indentationCharacter = $ this ->getIndentationCharacter ($ this ->getIndentationWhitespace ($ phpcsFile , $ prevIndex ));
171-
172- $ indentation = str_repeat ($ indentationCharacter , $ indentationLevel );
140+ $ indentation = $ this ->getIndentationWhitespace ($ phpcsFile , $ prevIndex );
173141
174142 for ($ i = $ prevIndex + 1 ; $ i < $ stackPtr ; $ i ++) {
175143 $ phpcsFile ->fixer ->replaceToken ($ i , '' );
0 commit comments