From 392b2b5f0e2a3a88f18fd619258c9f5fea527875 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Thu, 15 Feb 2024 14:38:15 +0000 Subject: [PATCH 1/2] Add auto-generated ".fixed" file --- ...losingDeclarationCommentUnitTest.inc.fixed | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed diff --git a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed new file mode 100644 index 0000000000..3288305c50 --- /dev/null +++ b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed @@ -0,0 +1,89 @@ + Date: Thu, 15 Feb 2024 14:49:49 +0000 Subject: [PATCH 2/2] Avoid adding extra newlines when adding a comment --- .../Sniffs/Commenting/ClosingDeclarationCommentSniff.php | 2 +- .../Commenting/ClosingDeclarationCommentUnitTest.inc.fixed | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php index 45bcdbdef6..afc7ac071a 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php @@ -110,7 +110,7 @@ public function process(File $phpcsFile, $stackPtr) } else { $fix = $phpcsFile->addFixableError('Expected %s', $closingBracket, 'Missing', $data); if ($fix === true) { - $phpcsFile->fixer->replaceToken($closingBracket, '}'.$comment.$phpcsFile->eolChar); + $phpcsFile->fixer->replaceToken($closingBracket, '}'.$comment); } } diff --git a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed index 3288305c50..4515c41a4b 100644 --- a/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/ClosingDeclarationCommentUnitTest.inc.fixed @@ -58,17 +58,14 @@ class TestClass { }//end class - abstract class TestClass { }//end class - interface TestClass { }//end interface - class MyClass { public function myFunction(); @@ -84,6 +81,5 @@ class TestClass enum MissingClosingComment { }//end enum - enum HasClosingComment { }//end enum