diff --git a/PhpCollective/Sniffs/Commenting/DocCommentSniff.php b/PhpCollective/Sniffs/Commenting/DocCommentSniff.php index 82df3b8..c30432b 100644 --- a/PhpCollective/Sniffs/Commenting/DocCommentSniff.php +++ b/PhpCollective/Sniffs/Commenting/DocCommentSniff.php @@ -75,8 +75,7 @@ public function process(File $phpcsFile, $stackPtr): void $error = 'The close comment tag must be the only content on the line'; $fix = $phpcsFile->addFixableError($error, $commentEnd, 'ContentBeforeClose'); if ($fix === true) { - $indentation = $tokens[$commentStart]['column'] - 1; - $indentation = str_repeat("\t", $indentation); + $indentation = $this->getIndentationWhitespace($phpcsFile, $commentStart); $phpcsFile->fixer->beginChangeset(); @@ -167,7 +166,7 @@ public function process(File $phpcsFile, $stackPtr): void $phpcsFile->fixer->replaceToken($i, ''); } - $indent = str_repeat("\t", $tokens[$stackPtr]['column'] - 1) . ' '; + $indent = $this->getIndentationWhitespace($phpcsFile, $stackPtr) . ' '; $phpcsFile->fixer->addContent($prev, $phpcsFile->eolChar . $indent . '*' . $phpcsFile->eolChar); $phpcsFile->fixer->endChangeset(); } diff --git a/tests/_data/DocComment/after.php b/tests/_data/DocComment/after.php index 4867b1c..c98f2f1 100644 --- a/tests/_data/DocComment/after.php +++ b/tests/_data/DocComment/after.php @@ -8,7 +8,7 @@ class DocCommentExample { /** * Close tag shares a line. - */ + */ public function closeTagSharesLine(): void { } @@ -29,7 +29,7 @@ public function extraBlankLineAtEnd(): void /** * Tags are too close. - * + * * @return void */ public function tagsNeedSpacing(): void