|
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\Comment\Doc; |
|
|
|
|
|
|
9
|
|
|
use PhpParser\Node\Param; |
|
|
|
|
|
|
10
|
|
|
use PhUml\Code\Parameters\Parameter; |
|
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
|
|
|
final class ParametersBuilder |
|
17
|
|
|
{ |
|
18
|
47 |
|
public function __construct( |
|
19
|
|
|
private readonly TypeBuilder $typeBuilder, |
|
|
|
|
|
|
20
|
|
|
private readonly ParameterTagFilterFactory $filterFactory |
|
21
|
|
|
) { |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param Param[] $parameters |
|
26
|
|
|
* @return Parameter[] |
|
27
|
|
|
*/ |
|
28
|
24 |
|
public function build(array $parameters, ?Doc $methodDocBlock, UseStatements $useStatements): array |
|
29
|
|
|
{ |
|
30
|
24 |
|
return array_map(function (Param $parameter) use ($methodDocBlock, $useStatements): Parameter { |
|
31
|
|
|
/** @var \PhpParser\Node\Expr\Variable $parsedParameter Since the parser throws error by default */ |
|
32
|
21 |
|
$parsedParameter = $parameter->var; |
|
33
|
|
|
|
|
34
|
|
|
/** @var string $parameterName Since it's a parameter not a variable */ |
|
35
|
21 |
|
$parameterName = $parsedParameter->name; |
|
36
|
|
|
|
|
37
|
21 |
|
$name = "\${$parameterName}"; |
|
38
|
21 |
|
$type = $parameter->type; |
|
39
|
|
|
|
|
40
|
21 |
|
$typeDeclaration = $this->typeBuilder->fromType( |
|
41
|
|
|
$type, |
|
42
|
|
|
$methodDocBlock, |
|
43
|
|
|
TagName::PARAM, |
|
44
|
|
|
$useStatements, |
|
45
|
21 |
|
$this->filterFactory->filter($name) |
|
46
|
|
|
); |
|
47
|
|
|
|
|
48
|
21 |
|
return new Parameter(new Variable($name, $typeDeclaration), $parameter->variadic, $parameter->byRef); |
|
49
|
|
|
}, $parameters); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
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