|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SavinMikhail\CommentsDensity\MissingDocblock; |
|
6
|
|
|
|
|
7
|
|
|
use ArrayAccess; |
|
8
|
|
|
use Iterator; |
|
9
|
|
|
use PhpParser\Node; |
|
10
|
|
|
use PhpParser\Node\ComplexType; |
|
11
|
|
|
use PhpParser\Node\Identifier; |
|
12
|
|
|
use PhpParser\Node\Name; |
|
13
|
|
|
use PhpParser\Node\Stmt\Class_; |
|
14
|
|
|
use PhpParser\Node\Stmt\ClassConst; |
|
15
|
|
|
use PhpParser\Node\Stmt\ClassMethod; |
|
16
|
|
|
use PhpParser\Node\Stmt\Enum_; |
|
17
|
|
|
use PhpParser\Node\Stmt\Function_; |
|
18
|
|
|
use PhpParser\Node\Stmt\Interface_; |
|
19
|
|
|
use PhpParser\Node\Stmt\Property; |
|
20
|
|
|
use PhpParser\Node\Stmt\Trait_; |
|
21
|
|
|
use PhpParser\NodeTraverser; |
|
22
|
|
|
use PhpParser\NodeVisitorAbstract; |
|
23
|
|
|
use ReflectionClass; |
|
24
|
|
|
use SavinMikhail\CommentsDensity\DTO\Input\MissingDocblockConfigDTO; |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
use function class_exists; |
|
27
|
|
|
use function in_array; |
|
28
|
|
|
|
|
29
|
|
|
final class MissingDocBlockVisitor extends NodeVisitorAbstract |
|
30
|
|
|
{ |
|
31
|
|
|
public array $missingDocBlocks = []; |
|
32
|
|
|
|
|
33
|
51 |
|
public function __construct( |
|
34
|
|
|
private readonly string $filename, |
|
35
|
|
|
private readonly DocBlockChecker $docBlockChecker, |
|
|
|
|
|
|
36
|
|
|
) { |
|
37
|
51 |
|
} |
|
38
|
|
|
|
|
39
|
51 |
|
public function enterNode(Node $node): void |
|
40
|
|
|
{ |
|
41
|
51 |
|
if (! $this->docBlockChecker->requiresDocBlock($node)) { |
|
42
|
51 |
|
return; |
|
43
|
|
|
} |
|
44
|
33 |
|
$docComment = $node->getDocComment(); |
|
45
|
33 |
|
if ($docComment !== null) { |
|
46
|
12 |
|
return; |
|
47
|
|
|
} |
|
48
|
31 |
|
$this->missingDocBlocks[] = [ |
|
49
|
31 |
|
'type' => 'missingDocblock', |
|
50
|
31 |
|
'content' => '', |
|
51
|
31 |
|
'file' => $this->filename, |
|
52
|
31 |
|
'line' => $node->getLine(), |
|
|
|
|
|
|
53
|
31 |
|
]; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths