@@ -368,6 +368,8 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $
368
368
// at a tab stop. Without this, the function will be indented a further
369
369
// $indent spaces to the right.
370
370
$ functionIndent = (int ) (floor ($ foundFunctionIndent / $ this ->indent ) * $ this ->indent );
371
+ $ adjustment = 0 ;
372
+
371
373
if ($ foundFunctionIndent !== $ functionIndent ) {
372
374
$ error = 'Opening statement of multi-line function call not indented correctly; expected %s spaces but found %s ' ;
373
375
$ data = [
@@ -377,7 +379,8 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $
377
379
378
380
$ fix = $ phpcsFile ->addFixableError ($ error , $ first , 'OpeningIndent ' , $ data );
379
381
if ($ fix === true ) {
380
- $ padding = str_repeat (' ' , $ functionIndent );
382
+ $ adjustment = ($ functionIndent - $ foundFunctionIndent );
383
+ $ padding = str_repeat (' ' , $ functionIndent );
381
384
if ($ foundFunctionIndent === 0 ) {
382
385
$ phpcsFile ->fixer ->addContentBefore ($ first , $ padding );
383
386
} else {
@@ -393,7 +396,7 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $
393
396
if ($ fix === true ) {
394
397
$ phpcsFile ->fixer ->addContent (
395
398
$ openBracket ,
396
- $ phpcsFile ->eolChar .str_repeat (' ' , ($ functionIndent + $ this ->indent ))
399
+ $ phpcsFile ->eolChar .str_repeat (' ' , ($ foundFunctionIndent + $ this ->indent ))
397
400
);
398
401
}
399
402
}
@@ -406,7 +409,7 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $
406
409
if ($ fix === true ) {
407
410
$ phpcsFile ->fixer ->addContentBefore (
408
411
$ closeBracket ,
409
- $ phpcsFile ->eolChar .str_repeat (' ' , ($ functionIndent + $ this ->indent ))
412
+ $ phpcsFile ->eolChar .str_repeat (' ' , ($ foundFunctionIndent + $ this ->indent ))
410
413
);
411
414
}
412
415
}
@@ -477,9 +480,9 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $
477
480
// Closing brace needs to be indented to the same level
478
481
// as the function call.
479
482
$ inArg = false ;
480
- $ expectedIndent = $ foundFunctionIndent ;
483
+ $ expectedIndent = ( $ foundFunctionIndent + $ adjustment ) ;
481
484
} else {
482
- $ expectedIndent = ($ functionIndent + $ this ->indent );
485
+ $ expectedIndent = ($ foundFunctionIndent + $ this ->indent + $ adjustment );
483
486
}
484
487
485
488
if ($ tokens [$ i ]['code ' ] !== T_WHITESPACE
@@ -565,7 +568,7 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $
565
568
566
569
$ phpcsFile ->fixer ->addContentBefore (
567
570
$ next ,
568
- $ phpcsFile ->eolChar .str_repeat (' ' , ($ functionIndent + $ this ->indent ))
571
+ $ phpcsFile ->eolChar .str_repeat (' ' , ($ foundFunctionIndent + $ this ->indent ))
569
572
);
570
573
$ phpcsFile ->fixer ->endChangeset ();
571
574
}
0 commit comments