Skip to content

Commit 919bbe6

Browse files
committed
avoid duplicate registration
1 parent f3f9c1a commit 919bbe6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Configuration/RectorConfigBuilder.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ final class RectorConfigBuilder
142142
*/
143143
private ?bool $isTypeCoverageLevelUsed = null;
144144

145+
private ?bool $isTypeCoverageDocblockLevelUsed = null;
146+
145147
private ?bool $isDeadCodeLevelUsed = null;
146148

147149
private ?bool $isCodeQualityLevelUsed = null;
@@ -225,6 +227,17 @@ public function __invoke(RectorConfig $rectorConfig): void
225227
));
226228
}
227229

230+
if (in_array(
231+
SetList::TYPE_DECLARATION_DOCBLOCKS,
232+
$uniqueSets,
233+
true
234+
) && $this->isTypeCoverageDocblockLevelUsed === true) {
235+
throw new InvalidConfigurationException(sprintf(
236+
'Your config already enables type declarations set.%sRemove "->withTypeCoverageDocblockLevel()" as it only duplicates it, or remove type declaration set.',
237+
PHP_EOL
238+
));
239+
}
240+
228241
if (in_array(SetList::DEAD_CODE, $uniqueSets, true) && $this->isDeadCodeLevelUsed === true) {
229242
throw new InvalidConfigurationException(sprintf(
230243
'Your config already enables dead code set.%sRemove "->withDeadCodeLevel()" as it only duplicates it, or remove dead code set.',
@@ -1030,6 +1043,8 @@ public function withTypeCoverageDocblockLevel(int $level): self
10301043
{
10311044
Assert::natural($level);
10321045

1046+
$this->isTypeCoverageDocblockLevelUsed = true;
1047+
10331048
$levelRules = LevelRulesResolver::resolve($level, TypeDeclarationDocblocksLevel::RULES, __METHOD__);
10341049

10351050
// too high

0 commit comments

Comments
 (0)