Skip to content

Commit e33d4ac

Browse files
committed
avoid adding duplicate tags
1 parent 8d441ec commit e33d4ac

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Console/ModelsCommand.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,11 @@ protected function createPhpDocs($class)
10481048

10491049
$tagLine = trim("@{$attr} {$property['type']} {$name} {$property['comment']}");
10501050
$tag = Tag::createInstance($tagLine, $phpdoc);
1051+
1052+
if ($this->tagExists($phpdoc, $tag)) {
1053+
continue;
1054+
}
1055+
10511056
$phpdoc->appendTag($tag);
10521057
}
10531058

@@ -1762,4 +1767,19 @@ protected function setForeignKeys($schema, $table)
17621767
}
17631768
}
17641769
}
1770+
1771+
/**
1772+
* @param DocBlock $phpdoc
1773+
* @param Tag $tag
1774+
*/
1775+
public function tagExists($phpdoc, $tag): bool
1776+
{
1777+
foreach ($phpdoc->getTags() as $originalTag) {
1778+
if ($originalTag->getContent() == $tag->getContent()) {
1779+
return true;
1780+
}
1781+
}
1782+
1783+
return false;
1784+
}
17651785
}

0 commit comments

Comments
 (0)