|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/** |
|
3
|
|
|
* This source file is subject to the license that is bundled with this package in the file LICENSE. |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace PhUml\Parser\Code\Builders\Members; |
|
7
|
|
|
|
|
8
|
|
|
use PhpParser\Node; |
|
|
|
|
|
|
9
|
|
|
use PhpParser\Node\Stmt\Property as ParsedProperty; |
|
|
|
|
|
|
10
|
|
|
use PhUml\Code\Properties\Property; |
|
11
|
|
|
use PhUml\Code\UseStatements; |
|
12
|
|
|
use PhUml\Code\Variables\Variable; |
|
13
|
|
|
use PhUml\Parser\Code\Builders\ParameterTagFilterFactory; |
|
14
|
|
|
use PhUml\Parser\Code\Builders\TagName; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* It builds an array of `Property` for a `ClassDefinition` or a `TraitDefinition` |
|
18
|
|
|
*/ |
|
19
|
|
|
final class ParsedPropertiesBuilder implements PropertiesBuilder |
|
20
|
|
|
{ |
|
21
|
44 |
|
public function __construct( |
|
22
|
|
|
private readonly VisibilityBuilder $visibilityBuilder, |
|
23
|
|
|
private readonly TypeBuilder $typeBuilder, |
|
|
|
|
|
|
24
|
|
|
private readonly ParameterTagFilterFactory $filterFactory |
|
25
|
|
|
) { |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param ParsedProperty[] $parsedProperties |
|
30
|
|
|
* @return Property[] |
|
31
|
|
|
*/ |
|
32
|
33 |
|
public function build(array $parsedProperties, UseStatements $useStatements): array |
|
33
|
|
|
{ |
|
34
|
33 |
|
return array_map(function (ParsedProperty $property) use ($useStatements): Property { |
|
35
|
19 |
|
$variable = new Variable( |
|
36
|
19 |
|
"\${$property->props[0]->name}", |
|
37
|
19 |
|
$this->typeBuilder->fromType($property->type, $property->getDocComment(), TagName::VAR, $useStatements) |
|
38
|
|
|
); |
|
39
|
19 |
|
$visibility = $this->visibilityBuilder->build($property); |
|
40
|
|
|
|
|
41
|
19 |
|
return new Property($variable, $visibility, $property->isStatic()); |
|
42
|
|
|
}, $parsedProperties); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param Node\Param[] $promotedProperties |
|
47
|
|
|
* @return Property[] |
|
48
|
|
|
*/ |
|
49
|
21 |
|
public function fromPromotedProperties(array $promotedProperties, UseStatements $useStatements): array |
|
50
|
|
|
{ |
|
51
|
21 |
|
return array_map(function (Node\Param $param) use ($useStatements): Property { |
|
|
|
|
|
|
52
|
|
|
/** @var Node\Expr\Variable $var */ |
|
53
|
9 |
|
$var = $param->var; |
|
54
|
|
|
|
|
55
|
|
|
/** @var string $name */ |
|
56
|
9 |
|
$name = $var->name; |
|
57
|
|
|
|
|
58
|
9 |
|
$type = $this->typeBuilder->fromType( |
|
59
|
9 |
|
$param->type, |
|
60
|
9 |
|
$param->getDocComment(), |
|
61
|
|
|
TagName::PARAM, |
|
62
|
|
|
$useStatements, |
|
63
|
9 |
|
$this->filterFactory->filter($name) |
|
64
|
|
|
); |
|
65
|
9 |
|
$visibility = $this->visibilityBuilder->fromFlags($param->flags); |
|
66
|
|
|
|
|
67
|
9 |
|
return new Property(new Variable("\$${name}", $type), $visibility); |
|
68
|
|
|
}, $promotedProperties); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
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