1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Divergence\Models\Mapping; |
4
|
|
|
|
5
|
|
|
use Attribute; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @Annotation |
9
|
|
|
* @NamedArgumentConstructor |
10
|
|
|
* @Target({"PROPERTY","ANNOTATION"}) |
11
|
|
|
*/ |
12
|
|
|
#[Attribute(Attribute::TARGET_PROPERTY)] |
13
|
|
|
final class Column implements MappingAttribute |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var string|null |
17
|
|
|
* @readonly |
18
|
|
|
*/ |
19
|
|
|
public $columnName; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var mixed |
23
|
|
|
* @readonly |
24
|
|
|
*/ |
25
|
|
|
public $type; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var int|null |
29
|
|
|
* @readonly |
30
|
|
|
*/ |
31
|
|
|
public $length; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The precision for a decimal (exact numeric) column (Applies only for decimal column). |
35
|
|
|
* |
36
|
|
|
* @var int|null |
37
|
|
|
* @readonly |
38
|
|
|
*/ |
39
|
|
|
public $precision = 0; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* The scale for a decimal (exact numeric) column (Applies only for decimal column). |
43
|
|
|
* |
44
|
|
|
* @var int|null |
45
|
|
|
* @readonly |
46
|
|
|
*/ |
47
|
|
|
public $scale = 0; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var bool |
51
|
|
|
* @readonly |
52
|
|
|
*/ |
53
|
|
|
public $unique = false; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var bool |
57
|
|
|
* @readonly |
58
|
|
|
*/ |
59
|
|
|
public $notnull = true; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var bool |
63
|
|
|
* @readonly |
64
|
|
|
*/ |
65
|
|
|
public $autoincrement; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var bool |
69
|
|
|
* @readonly |
70
|
|
|
*/ |
71
|
|
|
public $unsigned; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @var bool |
75
|
|
|
* @readonly |
76
|
|
|
*/ |
77
|
|
|
public $primary; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var bool |
81
|
|
|
* @readonly |
82
|
|
|
*/ |
83
|
|
|
public $insertable = true; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @var bool |
87
|
|
|
* @readonly |
88
|
|
|
*/ |
89
|
|
|
public $updatable = true; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var string|null |
93
|
|
|
* @readonly |
94
|
|
|
*/ |
95
|
|
|
public $delimiter = null; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @var array<string,mixed> |
99
|
|
|
* @readonly |
100
|
|
|
*/ |
101
|
|
|
public $values = []; |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @var array<string,mixed> |
105
|
|
|
* @readonly |
106
|
|
|
*/ |
107
|
|
|
public $options = []; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @var string|null |
111
|
|
|
* @readonly |
112
|
|
|
*/ |
113
|
|
|
public $columnDefinition; |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @var string|null |
117
|
|
|
* @readonly |
118
|
|
|
* @psalm-var 'NEVER'|'INSERT'|'ALWAYS'|null |
119
|
|
|
* @Enum({"NEVER", "INSERT", "ALWAYS"}) |
120
|
|
|
*/ |
121
|
|
|
public $generated; |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param array<string,mixed> $options |
125
|
|
|
* @psalm-param 'NEVER'|'INSERT'|'ALWAYS'|null $generated |
126
|
|
|
*/ |
127
|
|
|
public function __construct( |
128
|
|
|
?string $columnName = null, |
129
|
|
|
?string $type = null, |
130
|
|
|
?int $length = null, |
131
|
|
|
?int $precision = null, |
132
|
|
|
?int $scale = null, |
133
|
|
|
bool $unique = false, |
134
|
|
|
bool $notnull = true, |
135
|
|
|
bool $autoincrement = false, |
136
|
|
|
bool $unsigned = null, |
137
|
|
|
bool $primary = false, |
138
|
|
|
bool $insertable = true, |
139
|
|
|
bool $updatable = true, |
140
|
|
|
string $delimiter = null, |
141
|
|
|
array $values = [], |
142
|
|
|
array $options = [], |
143
|
|
|
?string $columnDefinition = null, |
144
|
|
|
?string $generated = null |
145
|
|
|
) { |
146
|
|
|
$this->columnName = $columnName; |
147
|
|
|
$this->type = $type; |
148
|
|
|
$this->length = $length; |
149
|
|
|
$this->precision = $precision; |
150
|
|
|
$this->scale = $scale; |
151
|
|
|
$this->unique = $unique; |
152
|
|
|
$this->notnull = $notnull; |
153
|
|
|
$this->autoincrement = $autoincrement; |
154
|
|
|
$this->unsigned = $unsigned; |
155
|
|
|
$this->primary = $primary; |
156
|
|
|
$this->insertable = $insertable; |
157
|
|
|
$this->updatable = $updatable; |
158
|
|
|
$this->delimiter = $delimiter; |
159
|
|
|
$this->values = $values; |
160
|
|
|
$this->options = $options; |
161
|
|
|
$this->columnDefinition = $columnDefinition; |
162
|
|
|
$this->generated = $generated; |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
|