Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/DocBlock/UselessDocBlockCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ final class UselessDocBlockCleaner
*/
private const COMMENT_CONSTRUCTOR_CLASS_REGEX = '#^(\/\/|(\s|\*)+)(\s\w+\s)?constructor(\.)?$#i';

/**
* @see https://regex101.com/r/1kcgR5/1
* @var string
*/
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+\*\/)$#';

public function clearDocTokenContent(Token $currentToken, ?string $classLikeName): string
{
$docContent = $currentToken->getContent();
Expand Down Expand Up @@ -87,7 +93,10 @@ public function clearDocTokenContent(Token $currentToken, ?string $classLikeName
return '';
}

return implode("\n", $cleanedCommentLines);
$commentText = implode("\n", $cleanedCommentLines);

// run multilines regex on final result
return Strings::replace($commentText, self::DOCTRINE_GENERATED_COMMENT_REGEX);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

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

/**
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class SomeClass1
{
}

?>
-----
<?php

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


class SomeClass1
{
}

?>