Skip to content

Commit b9ceead

Browse files
committed
implemented
1 parent 4ed1f6a commit b9ceead

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/DocBlock/UselessDocBlockCleaner.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ final class UselessDocBlockCleaner
6060
*/
6161
private const COMMENT_CONSTRUCTOR_CLASS_REGEX = '#^(\/\/|(\s|\*)+)(\s\w+\s)?constructor(\.)?$#i';
6262

63+
/**
64+
* @see https://regex101.com/r/1kcgR5/1
65+
* @var string
66+
*/
67+
private const DOCTRINE_GENERATED_COMMENT_REGEX = '#^(\/\*{2}\s+?)?(\*|\/\/)\s+This class was generated by the Doctrine ORM\. Add your own custom\r?\n\s+\*\s+repository methods below\.(\s+\*\/)$#';
68+
6369
public function clearDocTokenContent(Token $currentToken, ?string $classLikeName): string
6470
{
6571
$docContent = $currentToken->getContent();
@@ -87,7 +93,10 @@ public function clearDocTokenContent(Token $currentToken, ?string $classLikeName
8793
return '';
8894
}
8995

90-
return implode("\n", $cleanedCommentLines);
96+
$commentText = implode("\n", $cleanedCommentLines);
97+
98+
// run multilines regex on final result
99+
return Strings::replace($commentText, self::DOCTRINE_GENERATED_COMMENT_REGEX);
91100
}
92101

93102
/**

tests/Fixer/Commenting/RemoveUselessDefaultCommentFixer/Fixture/doctrine_generated.php.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class SomeClass1
1616

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

19+
1920
class SomeClass1
2021
{
2122
}

0 commit comments

Comments
 (0)