1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Jasny\PhpdocParser\Tag\PhpDocumentor; |
6
|
|
|
|
7
|
|
|
use Jasny\PhpdocParser\Tag\AbstractTag; |
8
|
|
|
use Jasny\PhpdocParser\notation; |
|
|
|
|
9
|
|
|
use function Jasny\array_only; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Custom logic for PhpDocumentor 'var', 'param' and 'property' tag |
13
|
|
|
*/ |
14
|
|
|
class VarTag extends AbstractTag |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var array |
18
|
|
|
*/ |
19
|
|
|
protected $additional; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var callable|null |
23
|
|
|
*/ |
24
|
|
|
protected $fqsenConvertor; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Class constructor. |
28
|
|
|
* |
29
|
|
|
* @param string $name Tag name |
30
|
|
|
* @param callable|null $fqsenConvertor Logic to convert class to FQCN |
31
|
|
|
* @param array $additional Additional properties |
32
|
|
|
*/ |
33
|
6 |
|
public function __construct(string $name, ?callable $fqsenConvertor = null, array $additional = []) |
34
|
|
|
{ |
35
|
6 |
|
parent::__construct($name); |
36
|
|
|
|
37
|
6 |
|
$this->fqsenConvertor = $fqsenConvertor; |
38
|
6 |
|
$this->additional = $additional; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Get additional properties that are always applied. |
43
|
|
|
* |
44
|
|
|
* @return array |
45
|
|
|
*/ |
46
|
1 |
|
public function getAdditionalProperties(): array |
47
|
|
|
{ |
48
|
1 |
|
return $this->additional; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Process a notation. |
53
|
|
|
* |
54
|
|
|
* @param array $notations |
55
|
|
|
* @param string $value |
56
|
|
|
* @return array |
57
|
|
|
*/ |
58
|
5 |
|
public function process(array $notations, string $value): array |
59
|
|
|
{ |
60
|
5 |
|
$regexp = '/^(?:(?<type>[^$\s]+)\s*)?(?:\$(?<name>\w+)\s*)?(?:"(?<id>[^"]+)"\s*)?(?:(?<description>.+))?/'; |
61
|
5 |
|
preg_match($regexp, $value, $props); //regexp won't fail |
62
|
|
|
|
63
|
5 |
|
$this->removeEmptyValues($props); |
64
|
|
|
|
65
|
5 |
|
if (isset($props['type']) && isset($this->fqsenConvertor)) { |
66
|
1 |
|
$props['type'] = call_user_func($this->fqsenConvertor, $props['type']); |
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
69
|
5 |
|
$props = array_only($props, ['type', 'name', 'id', 'description']); |
70
|
|
|
|
71
|
5 |
|
$notations[$this->name] = $props + $this->additional; |
72
|
|
|
|
73
|
5 |
|
return $notations; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Remove empty values from parsed data |
78
|
|
|
* |
79
|
|
|
* @param array $props |
80
|
|
|
*/ |
81
|
5 |
|
protected function removeEmptyValues(array &$props): void |
82
|
|
|
{ |
83
|
5 |
|
foreach (['type', 'name', 'id'] as $name) { |
84
|
5 |
|
if (isset($props[$name]) && $props[$name] === '') { |
85
|
2 |
|
unset($props[$name]); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
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