Skip to content

Commit

Permalink
update content only if changed
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Feb 23, 2024
1 parent eb8c151 commit 1a591e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Fixer/Commenting/RemoveUselessDefaultCommentFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ public function fix(SplFileInfo $fileInfo, Tokens $tokens): void
continue;
}

$originalContent = $token->getContent();
$cleanedDocContent = $this->uselessDocBlockCleaner->clearDocTokenContent($token);

if ($cleanedDocContent === '') {
// remove token
$tokens->clearTokenAndMergeSurroundingWhitespace($index);
} else {
} elseif ($cleanedDocContent !== $originalContent) {
// update in case of other contents
$tokens[$index] = new Token([T_DOC_COMMENT, $cleanedDocContent]);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Symplify\CodingStandard\Tests\Fixer\Commenting\RemoveUselessDefaultCommentFixer\Fixture;

final class SkipNoChanges
{
public function run()
{
// some line
$someLine = 100;

// another line
$someLine = 100;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);
use PhpCsFixer\Fixer\Basic\BracesFixer;

use Symplify\CodingStandard\Fixer\Commenting\RemoveUselessDefaultCommentFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;

Expand Down

0 comments on commit 1a591e1

Please sign in to comment.