1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/** |
3
|
|
|
* PHP version 8.0 |
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\UseStatements; |
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 ParsedMethodsBuilder implements MethodsBuilder |
24
|
|
|
{ |
25
|
|
|
public function __construct( |
26
|
|
|
private ParametersBuilder $parametersBuilder, |
27
|
|
|
private TypeBuilder $typeBuilder, |
28
|
|
|
private VisibilityBuilder $visibilityBuilder, |
29
|
|
|
) { |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param ClassMethod[] $methods |
34
|
|
|
* @return Method[] |
35
|
|
|
*/ |
36
|
|
|
public function build(array $methods, UseStatements $useStatements): array |
37
|
|
|
{ |
38
|
|
|
return array_map( |
39
|
|
|
fn (ClassMethod $method): Method => $this->buildMethod($method, $useStatements), |
40
|
|
|
$methods |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
private function buildMethod(ClassMethod $method, UseStatements $useStatements): Method |
45
|
|
|
{ |
46
|
|
|
$name = $method->name->name; |
47
|
|
|
$visibility = $this->visibilityBuilder->build($method); |
48
|
|
|
$docBlock = $method->getDocComment(); |
49
|
|
|
$returnType = $this->typeBuilder->fromMethodReturnType($method->returnType, $docBlock, $useStatements); |
50
|
|
|
$parameters = $this->parametersBuilder->build($method->params, $docBlock, $useStatements); |
51
|
|
|
return match (true) { |
52
|
|
|
$method->isAbstract() => new Method($name, $visibility, $returnType, $parameters, isAbstract: true), |
53
|
|
|
$method->isStatic() => new Method($name, $visibility, $returnType, $parameters, isStatic: true), |
54
|
|
|
default => new Method($name, $visibility, $returnType, $parameters), |
55
|
|
|
}; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
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