1313use SavinMikhail \CommentsDensity \AnalyzeComments \Analyzer \Visitors \MissingDocBlockVisitor ;
1414use SavinMikhail \CommentsDensity \AnalyzeComments \Comments \CommentTypeFactory ;
1515use SavinMikhail \CommentsDensity \AnalyzeComments \Config \DTO \ConfigDTO ;
16- use SavinMikhail \ CommentsDensity \ AnalyzeComments \ MissingDocblock \ MissingDocBlockAnalyzer ;
16+
1717use function in_array ;
1818
1919final readonly class CommentFinder
2323 public function __construct (
2424 private CommentTypeFactory $ commentFactory ,
2525 private ConfigDTO $ configDTO ,
26- private MissingDocBlockAnalyzer $ missingDocBlockAnalyzer ,
2726 ?Parser $ parser = null ,
2827 ) {
2928 $ this ->parser = $ parser ?? (new ParserFactory ())->createForHostVersion ();
@@ -36,14 +35,11 @@ public function run(string $content, string $filename): array
3635 {
3736 $ traverser = new NodeTraverser ();
3837
39- // $nameResolverVisitor = new NameResolver();
40- // $traverser->addVisitor($nameResolverVisitor);
41-
4238 $ missingDocBlockVisitor = new MissingDocBlockVisitor (
4339 $ filename ,
4440 new NodeNeedsDocblockChecker ($ this ->configDTO ->docblockConfigDTO ),
4541 );
46- if ($ this ->shouldAnalyzeMissingDocBlocks ( )) {
42+ if (in_array ( ' missingDocBlock ' , $ this ->configDTO -> getAllowedTypes (), true )) {
4743 $ traverser ->addVisitor ($ missingDocBlockVisitor );
4844 }
4945
@@ -57,15 +53,4 @@ public function run(string $content, string $filename): array
5753
5854 return [...$ missingDocBlockVisitor ->missingDocBlocks , ...$ commentVisitor ->comments ];
5955 }
60-
61- private function shouldAnalyzeMissingDocBlocks (): bool
62- {
63- return
64- $ this ->configDTO ->getAllowedTypes () === []
65- || in_array (
66- $ this ->missingDocBlockAnalyzer ->getName (),
67- $ this ->configDTO ->getAllowedTypes (),
68- true ,
69- );
70- }
7156}
0 commit comments