|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Doctrine\Annotations\Metadata; |
|
6
|
|
|
|
|
7
|
|
|
use function array_combine; |
|
8
|
|
|
use function array_filter; |
|
9
|
|
|
use function array_map; |
|
10
|
|
|
use function array_values; |
|
11
|
|
|
|
|
12
|
|
|
final class AnnotationMetadata |
|
13
|
|
|
{ |
|
14
|
|
|
/** @var string */ |
|
15
|
|
|
private $name; |
|
16
|
|
|
|
|
17
|
|
|
/** @var AnnotationTarget */ |
|
18
|
|
|
private $target; |
|
19
|
|
|
|
|
20
|
|
|
/** @var bool */ |
|
21
|
|
|
private $hasConstructor; |
|
22
|
|
|
|
|
23
|
|
|
/** @var PropertyMetadata[] */ |
|
24
|
|
|
private $properties; |
|
25
|
|
|
|
|
26
|
|
|
/** @var PropertyMetadata|null */ |
|
27
|
|
|
private $defaultProperty; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param PropertyMetadata[] $properties |
|
31
|
|
|
*/ |
|
32
|
278 |
|
public function __construct( |
|
33
|
|
|
string $name, |
|
34
|
|
|
AnnotationTarget $target, |
|
35
|
|
|
bool $hasConstructor, |
|
36
|
|
|
PropertyMetadata ...$properties |
|
37
|
|
|
) { |
|
38
|
278 |
|
$this->name = $name; |
|
39
|
278 |
|
$this->target = $target; |
|
40
|
278 |
|
$this->hasConstructor = $hasConstructor; |
|
41
|
278 |
|
$this->properties = array_combine( |
|
42
|
|
|
array_map(static function (PropertyMetadata $property) : string { |
|
43
|
278 |
|
return $property->getName(); |
|
44
|
278 |
|
}, $properties), |
|
45
|
278 |
|
$properties |
|
46
|
|
|
); |
|
47
|
278 |
|
$this->defaultProperty = array_values( |
|
48
|
|
|
array_filter($properties, static function (PropertyMetadata $property) : bool { |
|
49
|
278 |
|
return $property->isDefault(); |
|
50
|
278 |
|
}) |
|
51
|
278 |
|
)[0] ?? null; |
|
52
|
278 |
|
} |
|
53
|
|
|
|
|
54
|
278 |
|
public function getName() : string |
|
55
|
|
|
{ |
|
56
|
278 |
|
return $this->name; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
242 |
|
public function getTarget() : AnnotationTarget |
|
60
|
|
|
{ |
|
61
|
242 |
|
return $this->target; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
225 |
|
public function hasConstructor() : bool |
|
65
|
|
|
{ |
|
66
|
225 |
|
return $this->hasConstructor; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return PropertyMetadata[] |
|
71
|
|
|
*/ |
|
72
|
225 |
|
public function getProperties() : array |
|
73
|
|
|
{ |
|
74
|
225 |
|
return $this->properties; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
124 |
|
public function getDefaultProperty() : ?PropertyMetadata |
|
78
|
|
|
{ |
|
79
|
124 |
|
return $this->defaultProperty; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|