From 86cb18371c73178b05c4796e580678208c7e7d75 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Fri, 27 Oct 2023 18:08:49 +0100 Subject: [PATCH] Auto-fix PEAR.Commenting.FunctionComment.SpacingAfter --- .../PEAR/Sniffs/Commenting/FunctionCommentSniff.php | 7 ++++++- .../Tests/Commenting/FunctionCommentUnitTest.inc.fixed | 4 ---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php index 408856fc5a..310f8de56f 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php @@ -129,7 +129,12 @@ public function process(File $phpcsFile, $stackPtr) && $tokens[$i]['line'] !== $tokens[($i + 1)]['line'] ) { $error = 'There must be no blank lines after the function comment'; - $phpcsFile->addError($error, $commentEnd, 'SpacingAfter'); + $fix = $phpcsFile->addFixableError($error, $commentEnd, 'SpacingAfter'); + + if ($fix === true) { + $phpcsFile->fixer->replaceToken($i, ''); + } + break; } } diff --git a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc.fixed b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc.fixed index 751b09c665..a5fabee170 100644 --- a/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc.fixed +++ b/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc.fixed @@ -453,7 +453,6 @@ class Something implements JsonSerializable { * * @return mixed */ - #[ReturnTypeWillChange] public function blankLineDetectionA() {} @@ -463,7 +462,6 @@ class Something implements JsonSerializable { * @return mixed */ #[ReturnTypeWillChange] - public function blankLineDetectionB() {} /** @@ -471,8 +469,6 @@ class Something implements JsonSerializable { * * @return mixed */ - #[ReturnTypeWillChange] - public function blankLineDetectionC() {} }