|
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
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* It builds an array of `Property` for a `ClassDefinition` or a `TraitDefinition` |
|
16
|
|
|
*/ |
|
17
|
|
|
final class ParsedPropertiesBuilder implements PropertiesBuilder |
|
18
|
|
|
{ |
|
19
|
43 |
|
public function __construct( |
|
20
|
|
|
private readonly VisibilityBuilder $visibilityBuilder, |
|
21
|
|
|
private readonly TypeBuilder $typeBuilder, |
|
22
|
|
|
) { |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param ParsedProperty[] $parsedProperties |
|
27
|
|
|
* @return Property[] |
|
28
|
|
|
*/ |
|
29
|
32 |
|
public function build(array $parsedProperties, UseStatements $useStatements): array |
|
30
|
|
|
{ |
|
31
|
32 |
|
return array_map(function (ParsedProperty $property) use ($useStatements): Property { |
|
32
|
18 |
|
$variable = new Variable( |
|
33
|
18 |
|
"\${$property->props[0]->name}", |
|
34
|
18 |
|
$this->typeBuilder->fromPropertyType($property->type, $property->getDocComment(), $useStatements) |
|
35
|
|
|
); |
|
36
|
18 |
|
$visibility = $this->visibilityBuilder->build($property); |
|
37
|
|
|
|
|
38
|
18 |
|
return new Property($variable, $visibility, $property->isStatic()); |
|
39
|
|
|
}, $parsedProperties); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param Node\Param[] $promotedProperties |
|
44
|
|
|
* @return Property[] |
|
45
|
|
|
*/ |
|
46
|
20 |
|
public function fromPromotedProperties(array $promotedProperties, UseStatements $useStatements): array |
|
47
|
|
|
{ |
|
48
|
20 |
|
return array_map(function (Node\Param $param) use ($useStatements): Property { |
|
|
|
|
|
|
49
|
|
|
/** @var Node\Expr\Variable $var */ |
|
50
|
9 |
|
$var = $param->var; |
|
51
|
|
|
|
|
52
|
|
|
/** @var string $name */ |
|
53
|
9 |
|
$name = $var->name; |
|
54
|
|
|
|
|
55
|
9 |
|
$type = $this->typeBuilder->fromMethodParameter( |
|
56
|
9 |
|
$param->type, |
|
57
|
9 |
|
$param->getDocComment(), |
|
58
|
|
|
$name, |
|
59
|
|
|
$useStatements |
|
60
|
|
|
); |
|
61
|
9 |
|
$visibility = $this->visibilityBuilder->fromFlags($param->flags); |
|
62
|
|
|
|
|
63
|
9 |
|
return new Property(new Variable("\$${name}", $type), $visibility); |
|
64
|
|
|
}, $promotedProperties); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
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