|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/** |
|
3
|
|
|
* PHP version 7.2 |
|
4
|
|
|
* |
|
5
|
|
|
* This source file is subject to the license that is bundled with this package in the file LICENSE. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace PhUml\Parser\Code\Builders\Members; |
|
9
|
|
|
|
|
10
|
|
|
use PhpParser\Node\Stmt\ClassMethod; |
|
|
|
|
|
|
11
|
|
|
use PhUml\Code\Methods\Method; |
|
12
|
|
|
use PhUml\Code\Methods\MethodDocBlock; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* It builds an array with `Method`s for a `ClassDefinition`, an `InterfaceDefinition` or a |
|
16
|
|
|
* `TraitDefinition` |
|
17
|
|
|
* |
|
18
|
|
|
* It can run one or more `VisibilityFilter`s |
|
19
|
|
|
* |
|
20
|
|
|
* @see PrivateVisibilityFilter |
|
21
|
|
|
* @see ProtectedVisibilityFilter |
|
22
|
|
|
*/ |
|
23
|
|
|
final class FilteredMethodsBuilder implements MethodsBuilder |
|
24
|
|
|
{ |
|
25
|
|
|
/** @var ParametersBuilder */ |
|
26
|
|
|
private $parametersBuilder; |
|
27
|
|
|
|
|
28
|
|
|
/** @var VisibilityBuilder */ |
|
29
|
|
|
private $visibilityBuilder; |
|
30
|
|
|
|
|
31
|
|
|
/** @var TypeBuilder */ |
|
32
|
|
|
private $typeBuilder; |
|
33
|
|
|
|
|
34
|
|
|
/** @var VisibilityFilters */ |
|
35
|
|
|
private $visibilityFilters; |
|
36
|
|
|
|
|
37
|
|
|
public function __construct( |
|
38
|
|
|
ParametersBuilder $parametersBuilder, |
|
39
|
|
|
TypeBuilder $typeBuilder, |
|
40
|
|
|
VisibilityBuilder $visibilityBuilder, |
|
41
|
|
|
VisibilityFilters $filters |
|
42
|
|
|
) { |
|
43
|
|
|
$this->visibilityFilters = $filters; |
|
44
|
|
|
$this->typeBuilder = $typeBuilder; |
|
45
|
|
|
$this->parametersBuilder = $parametersBuilder; |
|
46
|
|
|
$this->visibilityBuilder = $visibilityBuilder; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param ClassMethod[] $methods |
|
51
|
|
|
* @return Method[] |
|
52
|
|
|
*/ |
|
53
|
|
|
public function build(array $methods): array |
|
54
|
|
|
{ |
|
55
|
|
|
return array_map(function (ClassMethod $method): Method { |
|
56
|
|
|
return $this->buildMethod($method); |
|
57
|
|
|
}, $this->visibilityFilters->apply($methods)); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
private function buildMethod(ClassMethod $method): Method |
|
61
|
|
|
{ |
|
62
|
|
|
$name = $method->name->name; |
|
63
|
|
|
$visibility = $this->visibilityBuilder->build($method); |
|
64
|
|
|
$docBlock = $method->getDocComment() === null ? null : $method->getDocComment()->getText(); |
|
65
|
|
|
$methodDocBlock = MethodDocBlock::from($docBlock); |
|
66
|
|
|
$returnType = $this->typeBuilder->fromMethodReturnType($method->returnType, $methodDocBlock); |
|
67
|
|
|
$parameters = $this->parametersBuilder->build($method->params, $methodDocBlock); |
|
68
|
|
|
switch (true) { |
|
69
|
|
|
case $method->isAbstract(): |
|
70
|
|
|
return new Method($name, $visibility, $returnType, $parameters, true); |
|
71
|
|
|
case $method->isStatic(): |
|
72
|
|
|
return new Method($name, $visibility, $returnType, $parameters, false, true); |
|
73
|
|
|
default: |
|
74
|
|
|
return new Method($name, $visibility, $returnType, $parameters); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
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