diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php index b5e8695c15..dab9a8e0b2 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php @@ -340,7 +340,8 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $ // call itself is, so we can work out how far to // indent the arguments. $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr, true); - if ($tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING + if ($first !== false + && $tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING && $tokens[($first - 1)]['code'] === T_CONSTANT_ENCAPSED_STRING ) { // We are in a multi-line string, so find the start and use @@ -386,8 +387,10 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $ $fix = $phpcsFile->addFixableError($error, $first, 'OpeningIndent', $data); if ($fix === true) { + // Set adjustment for use later to determine whether argument indentation is correct when fixing. $adjustment = ($functionIndent - $foundFunctionIndent); - $padding = str_repeat(' ', $functionIndent); + + $padding = str_repeat(' ', $functionIndent); if ($foundFunctionIndent === 0) { $phpcsFile->fixer->addContentBefore($first, $padding); } else if ($tokens[$first]['code'] === T_INLINE_HTML) { diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc index 612748fedf..fddd3cba18 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc @@ -567,3 +567,10 @@ content
+ + + + + diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed index 00226de562..1c52523075 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed @@ -582,3 +582,10 @@ content + + + + + diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php index 4984de2bf6..de6366b77c 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php @@ -134,6 +134,8 @@ public function getErrorList($testFile='FunctionCallSignatureUnitTest.inc') 559 => 1, 567 => 1, 568 => 1, + 573 => 1, + 574 => 1, ]; }//end getErrorList()