1111use Rector \Config \Level \CodeQualityLevel ;
1212use Rector \Config \Level \CodingStyleLevel ;
1313use Rector \Config \Level \DeadCodeLevel ;
14+ use Rector \Config \Level \TypeDeclarationDocblocksLevel ;
1415use Rector \Config \Level \TypeDeclarationLevel ;
1516use Rector \Config \RectorConfig ;
1617use Rector \Config \RegisteredService ;
@@ -742,6 +743,7 @@ public function withPreparedSets(
742743 bool $ codeQuality = false ,
743744 bool $ codingStyle = false ,
744745 bool $ typeDeclarations = false ,
746+ bool $ typeDeclarationDocblocks = false ,
745747 bool $ privatization = false ,
746748 bool $ naming = false ,
747749 bool $ instanceOf = false ,
@@ -761,6 +763,7 @@ public function withPreparedSets(
761763 SetList::CODE_QUALITY => $ codeQuality ,
762764 SetList::CODING_STYLE => $ codingStyle ,
763765 SetList::TYPE_DECLARATION => $ typeDeclarations ,
766+ SetList::TYPE_DECLARATION_DOCBLOCKS => $ typeDeclarationDocblocks ,
764767 SetList::PRIVATIZATION => $ privatization ,
765768 SetList::NAMING => $ naming ,
766769 SetList::INSTANCEOF => $ instanceOf ,
@@ -1019,6 +1022,33 @@ public function withTypeCoverageLevel(int $level): self
10191022 return $ this ;
10201023 }
10211024
1025+ /**
1026+ * Raise your type coverage docblock from the safest type rules
1027+ * to more affecting ones, one level at a time
1028+ */
1029+ public function withTypeCoverageDocblockLevel (int $ level ): self
1030+ {
1031+ Assert::natural ($ level );
1032+
1033+ $ levelRules = LevelRulesResolver::resolve ($ level , TypeDeclarationDocblocksLevel::RULES , __METHOD__ );
1034+
1035+ // too high
1036+ $ levelRulesCount = count ($ levelRules );
1037+ if ($ levelRulesCount + self ::MAX_LEVEL_GAP < $ level ) {
1038+ $ this ->levelOverflows [] = new LevelOverflow (
1039+ __METHOD__ ,
1040+ $ level ,
1041+ $ levelRulesCount ,
1042+ 'TypeDeclarationDocblocksLevel ' ,
1043+ 'TYPE_DECLARATION_DOCBLOCKS '
1044+ );
1045+ }
1046+
1047+ $ this ->rules = array_merge ($ this ->rules , $ levelRules );
1048+
1049+ return $ this ;
1050+ }
1051+
10221052 /**
10231053 * Raise your dead-code coverage from the safest rules
10241054 * to more affecting ones, one level at a time
0 commit comments