From b671e1e4c15ad840af7ccd634ed399db7f6010d8 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Thu, 6 Aug 2026 13:18:44 +0200 Subject: [PATCH] Fix DocBlockTagGrouping reporting a fix it never applied checkBeginningOfDocBlock() returned as soon as addFixableError() came back true, so the fixer body ran only when the fixer was switched off. phpcbf listed NoExtraNewlineBeforeTags as fixable and then left the blank line in place, every time. Every other fixable error in the file guards with `if (!$fix)`. This one had the condition inverted. The fixture added with the smoke tests recorded the broken output; it now records the blank line actually being removed. --- PhpCollective/Sniffs/Commenting/DocBlockTagGroupingSniff.php | 2 +- tests/_data/DocBlockTagGrouping/after.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/PhpCollective/Sniffs/Commenting/DocBlockTagGroupingSniff.php b/PhpCollective/Sniffs/Commenting/DocBlockTagGroupingSniff.php index 32b68ed..aea9852 100644 --- a/PhpCollective/Sniffs/Commenting/DocBlockTagGroupingSniff.php +++ b/PhpCollective/Sniffs/Commenting/DocBlockTagGroupingSniff.php @@ -175,7 +175,7 @@ protected function checkBeginningOfDocBlock(File $phpcsFile, int $docBlockStartI } $fix = $phpcsFile->addFixableError('Expected no extra blank line before tags, got ' . ($diff - 1), $nextIndex, 'NoExtraNewlineBeforeTags'); - if ($fix) { + if (!$fix) { return; } diff --git a/tests/_data/DocBlockTagGrouping/after.php b/tests/_data/DocBlockTagGrouping/after.php index 2f53ae4..1953e67 100644 --- a/tests/_data/DocBlockTagGrouping/after.php +++ b/tests/_data/DocBlockTagGrouping/after.php @@ -7,7 +7,6 @@ class DocBlockTagGroupingExample { /** - * * @var string */ public const TAGS_START_TOO_LATE = 'start';