|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Doctrine\Annotations\Parser\Visitor; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\Annotations\Parser\Ast\Annotation; |
|
8
|
|
|
use Doctrine\Annotations\Parser\Ast\Annotations; |
|
9
|
|
|
use Doctrine\Annotations\Parser\Ast\ClassConstantFetch; |
|
10
|
|
|
use Doctrine\Annotations\Parser\Ast\Collection\Collection; |
|
11
|
|
|
use Doctrine\Annotations\Parser\Ast\Collection\Entry; |
|
12
|
|
|
use Doctrine\Annotations\Parser\Ast\Collection\Key; |
|
|
|
|
|
|
13
|
|
|
use Doctrine\Annotations\Parser\Ast\ConstantFetch; |
|
14
|
|
|
use Doctrine\Annotations\Parser\Ast\Node; |
|
15
|
|
|
use Doctrine\Annotations\Parser\Ast\Pair; |
|
16
|
|
|
use Doctrine\Annotations\Parser\Ast\Parameter\NamedParameter; |
|
17
|
|
|
use Doctrine\Annotations\Parser\Ast\Parameter\UnnamedParameter; |
|
18
|
|
|
use Doctrine\Annotations\Parser\Ast\Parameters; |
|
19
|
|
|
use Doctrine\Annotations\Parser\Ast\Reference; |
|
20
|
|
|
use Doctrine\Annotations\Parser\Ast\Scalar\BooleanScalar; |
|
21
|
|
|
use Doctrine\Annotations\Parser\Ast\Scalar\FloatScalar; |
|
22
|
|
|
use Doctrine\Annotations\Parser\Ast\Scalar\Identifier; |
|
23
|
|
|
use Doctrine\Annotations\Parser\Ast\Scalar\IntegerScalar; |
|
24
|
|
|
use Doctrine\Annotations\Parser\Ast\Scalar\NullScalar; |
|
25
|
|
|
use Doctrine\Annotations\Parser\Ast\Scalar\StringScalar; |
|
26
|
|
|
use const JSON_PRESERVE_ZERO_FRACTION; |
|
27
|
|
|
use const JSON_UNESCAPED_UNICODE; |
|
28
|
|
|
use function count; |
|
29
|
|
|
use function json_encode; |
|
30
|
|
|
use function str_repeat; |
|
31
|
|
|
use function strlen; |
|
32
|
|
|
use function substr; |
|
33
|
|
|
|
|
34
|
|
|
final class Dumper implements Visitor |
|
35
|
|
|
{ |
|
36
|
|
|
private const INDENT = '> '; |
|
37
|
|
|
|
|
38
|
|
|
/** @var int */ |
|
39
|
|
|
private $depth = 0; |
|
40
|
|
|
|
|
41
|
|
|
public function visit(Node $node) : void |
|
42
|
|
|
{ |
|
43
|
|
|
$node->dispatch($this); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function visitAnnotations(Annotations $annotations) : void |
|
47
|
|
|
{ |
|
48
|
|
|
$this->print(Annotations::class); |
|
49
|
|
|
|
|
50
|
|
|
$this->depth++; |
|
51
|
|
|
foreach ($annotations as $annotation) { |
|
52
|
|
|
$annotation->dispatch($this); |
|
53
|
|
|
} |
|
54
|
|
|
$this->depth--; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function visitAnnotation(Annotation $annotation) : void |
|
58
|
|
|
{ |
|
59
|
|
|
$this->print(Annotation::class); |
|
60
|
|
|
|
|
61
|
|
|
$this->depth++; |
|
62
|
|
|
$annotation->getName()->dispatch($this); |
|
63
|
|
|
$annotation->getParameters()->dispatch($this); |
|
64
|
|
|
$this->depth--; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function visitReference(Reference $reference) : void |
|
68
|
|
|
{ |
|
69
|
|
|
$this->print( |
|
70
|
|
|
Reference::class, |
|
71
|
|
|
['identifier' => $reference->getIdentifier(), 'fully_qualified' => $reference->isFullyQualified()] |
|
72
|
|
|
); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function visitParameters(Parameters $parameters) : void |
|
76
|
|
|
{ |
|
77
|
|
|
$this->print(Parameters::class); |
|
78
|
|
|
|
|
79
|
|
|
$this->depth++; |
|
80
|
|
|
foreach ($parameters as $parameter) { |
|
81
|
|
|
$parameter->dispatch($this); |
|
82
|
|
|
} |
|
83
|
|
|
$this->depth--; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function visitNamedParameter(NamedParameter $parameter) : void |
|
87
|
|
|
{ |
|
88
|
|
|
$this->print(NamedParameter::class); |
|
89
|
|
|
|
|
90
|
|
|
$this->depth++; |
|
91
|
|
|
$parameter->getName()->dispatch($this); |
|
92
|
|
|
$parameter->getValue()->dispatch($this); |
|
93
|
|
|
$this->depth--; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function visitUnnamedParameter(UnnamedParameter $parameter) : void |
|
97
|
|
|
{ |
|
98
|
|
|
$this->print(UnnamedParameter::class); |
|
99
|
|
|
|
|
100
|
|
|
$this->depth++; |
|
101
|
|
|
$parameter->getValue()->dispatch($this); |
|
102
|
|
|
$this->depth--; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public function visitCollection(Collection $collection) : void |
|
106
|
|
|
{ |
|
107
|
|
|
$this->print(Collection::class); |
|
108
|
|
|
|
|
109
|
|
|
$this->depth++; |
|
110
|
|
|
foreach ($collection as $item) { |
|
111
|
|
|
$item->dispatch($this); |
|
112
|
|
|
} |
|
113
|
|
|
$this->depth--; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function visitCollectionEntry(Entry $entry) : void |
|
117
|
|
|
{ |
|
118
|
|
|
$this->print(Entry::class); |
|
119
|
|
|
|
|
120
|
|
|
$this->depth++; |
|
121
|
|
|
|
|
122
|
|
|
$key = $entry->getKey(); |
|
123
|
|
|
if ($key !== null) { |
|
124
|
|
|
$key->dispatch($this); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
$entry->getValue()->dispatch($this); |
|
128
|
|
|
|
|
129
|
|
|
$this->depth--; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function visitPair(Pair $pair) : void |
|
133
|
|
|
{ |
|
134
|
|
|
$this->print(Pair::class); |
|
135
|
|
|
|
|
136
|
|
|
$this->depth++; |
|
137
|
|
|
$pair->getKey()->dispatch($this); |
|
138
|
|
|
$pair->getValue()->dispatch($this); |
|
139
|
|
|
$this->depth--; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
public function visitIdentifier(Identifier $identifier) : void |
|
143
|
|
|
{ |
|
144
|
|
|
$this->print(Identifier::class, ['value' => $identifier->getValue()]); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
public function visitConstantFetch(ConstantFetch $constantFetch) : void |
|
148
|
|
|
{ |
|
149
|
|
|
$this->print(ConstantFetch::class); |
|
150
|
|
|
|
|
151
|
|
|
$this->depth++; |
|
152
|
|
|
$constantFetch->getName()->dispatch($this); |
|
153
|
|
|
$this->depth--; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
public function visitClassConstantFetch(ClassConstantFetch $classConstantFetch) : void |
|
157
|
|
|
{ |
|
158
|
|
|
$this->print(ClassConstantFetch::class); |
|
159
|
|
|
|
|
160
|
|
|
$this->depth++; |
|
161
|
|
|
$classConstantFetch->getClass()->dispatch($this); |
|
162
|
|
|
$classConstantFetch->getName()->dispatch($this); |
|
163
|
|
|
$this->depth--; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
public function visitNullScalar(NullScalar $nullScalar) : void |
|
167
|
|
|
{ |
|
168
|
|
|
$this->print(NullScalar::class, ['value' => $nullScalar->getValue()]); |
|
|
|
|
|
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
public function visitBooleanScalar(BooleanScalar $booleanScalar) : void |
|
172
|
|
|
{ |
|
173
|
|
|
$this->print(BooleanScalar::class, ['value' => $booleanScalar->getValue()]); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
public function visitIntegerScalar(IntegerScalar $integerScalar) : void |
|
177
|
|
|
{ |
|
178
|
|
|
$this->print(IntegerScalar::class, ['value' => $integerScalar->getValue()]); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
public function visitFloatScalar(FloatScalar $floatScalar) : void |
|
182
|
|
|
{ |
|
183
|
|
|
$this->print(FloatScalar::class, ['value' => $floatScalar->getValue()]); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
public function visitStringScalar(StringScalar $stringScalar) : void |
|
187
|
|
|
{ |
|
188
|
|
|
$this->print(StringScalar::class, ['value' => $stringScalar->getValue()]); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* @param mixed[] $data |
|
193
|
|
|
*/ |
|
194
|
|
|
private function print(string $name, array $data = []) : void |
|
195
|
|
|
{ |
|
196
|
|
|
echo str_repeat(self::INDENT, $this->depth + 1); |
|
197
|
|
|
echo substr($name, strlen(Node::class) - 4); |
|
198
|
|
|
|
|
199
|
|
|
if (count($data) !== 0) { |
|
200
|
|
|
echo ' ', json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION); |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
echo "\n"; |
|
204
|
|
|
} |
|
205
|
|
|
} |
|
206
|
|
|
|
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