|
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; |
|
|
|
|
|
|
11
|
|
|
use PhpParser\Node\Stmt\Property; |
|
|
|
|
|
|
12
|
|
|
use PhUml\Code\Attributes\Attribute; |
|
13
|
|
|
use PhUml\Code\Attributes\AttributeDocBlock; |
|
14
|
|
|
use PhUml\Code\Variables\Variable; |
|
15
|
|
|
use PhUml\Parser\Code\Builders\Filters\PrivateVisibilityFilter; |
|
16
|
|
|
use PhUml\Parser\Code\Builders\Filters\ProtectedVisibilityFilter; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* It builds an array of `Attributes` for a `ClassDefinition` or a `TraitDefinition` |
|
20
|
|
|
* |
|
21
|
|
|
* It applies one or more `VisibilityFilter`s |
|
22
|
|
|
* |
|
23
|
|
|
* @see PrivateVisibilityFilter |
|
24
|
|
|
* @see ProtectedVisibilityFilter |
|
25
|
|
|
*/ |
|
26
|
|
|
final class FilteredAttributesBuilder implements AttributesBuilder |
|
27
|
|
|
{ |
|
28
|
|
|
/** @var VisibilityBuilder */ |
|
29
|
|
|
private $visibilityBuilder; |
|
30
|
|
|
|
|
31
|
|
|
/** @var VisibilityFilters */ |
|
32
|
|
|
private $visibilityFilters; |
|
33
|
|
|
|
|
34
|
|
|
public function __construct(VisibilityBuilder $visibilityBuilder, VisibilityFilters $filters) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->visibilityBuilder = $visibilityBuilder; |
|
37
|
|
|
$this->visibilityFilters = $filters; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param Node[] $parsedAttributes |
|
42
|
|
|
* @return Attribute[] |
|
43
|
|
|
*/ |
|
44
|
|
|
public function build(array $parsedAttributes): array |
|
45
|
|
|
{ |
|
46
|
|
|
$attributes = array_filter($parsedAttributes, static function ($attribute): bool { |
|
47
|
|
|
return $attribute instanceof Property; |
|
48
|
|
|
}); |
|
49
|
|
|
|
|
50
|
|
|
return array_map(function (Property $attribute): Attribute { |
|
51
|
|
|
$name = "\${$attribute->props[0]->name}"; |
|
52
|
|
|
$visibility = $this->visibilityBuilder->build($attribute); |
|
53
|
|
|
$comment = $attribute->getDocComment() === null ? null : $attribute->getDocComment()->getText(); |
|
54
|
|
|
$docBlock = AttributeDocBlock::from($comment); |
|
55
|
|
|
$variable = new Variable($name, $docBlock->extractType()); |
|
56
|
|
|
|
|
57
|
|
|
return new Attribute($variable, $visibility, $attribute->isStatic()); |
|
58
|
|
|
}, $this->visibilityFilters->apply($attributes)); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
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