Unverified Commit 6fc09fdc authored by Nick Dickinson-Wilde's avatar Nick Dickinson-Wilde Committed by GitHub
Browse files

fix(FunctionComment): Fix PHP fatal error on phpcbf runs on param indentation...

fix(FunctionComment): Fix PHP fatal error on phpcbf runs on param indentation (#/3212527 by NickDickinsonWilde)
parent 5f3b3c01
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -822,7 +822,7 @@ class FunctionCommentSniff implements Sniff
                            continue;
                        }

                        $newIndent = ($param['commentLines'][$lineNum]['indent'] + $spaces - $param['type_space']);
                        $newIndent = max(($param['commentLines'][$lineNum]['indent'] + $spaces - $param['type_space']), 0);
                        $phpcsFile->fixer->replaceToken(
                            ($param['commentLines'][$lineNum]['token'] - 1),
                            str_repeat(' ', $newIndent)
+18 −0
Original line number Diff line number Diff line
@@ -526,3 +526,21 @@ function test38($a, $b) {
function test39(mixed $arg) {
  return $arg;
}

/**
 * Test multiline comments with excess spaces in the param annotation.
 */
class Test40 {

    /**
     * Test method.
     *
     * @param string      $errorMessage
     *   It only breaks when this comment spans multiple lines but won't break if
     * you put it on a single line.
     */
    public function test41(string $errorMessage) {

    }

}
+18 −0
Original line number Diff line number Diff line
@@ -552,3 +552,21 @@ function test38($a, $b) {
function test39(mixed $arg) {
  return $arg;
}

/**
 * Test multiline comments with excess spaces in the param annotation.
 */
class Test40 {

  /**
   * Test method.
   *
   * @param string $errorMessage
   *   It only breaks when this comment spans multiple lines but won't break if
   *   you put it on a single line.
   */
  public function test41(string $errorMessage) {

  }

}
+2 −0
Original line number Diff line number Diff line
@@ -74,6 +74,8 @@ class FunctionCommentUnitTest extends CoderSniffUnitTest
                427 => 2,
                450 => 1,
                460 => 1,
                538 => 1,
                540 => 1,
            ];
        case 'FunctionCommentUnitTest.1.inc':
            return [];