|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © 2016 netz98 new media GmbH. All rights reserved. |
|
4
|
|
|
* See COPYING.txt for license details. |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace N98\Magento\Command\Developer\Console\Structure; |
|
8
|
|
|
|
|
9
|
|
|
use Magento\Framework\DB\Ddl\Table; |
|
10
|
|
|
|
|
11
|
|
|
class DDLTableColumn |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var array |
|
15
|
|
|
*/ |
|
16
|
|
|
private $intTypes = [ |
|
17
|
|
|
Table::TYPE_BIGINT, |
|
18
|
|
|
Table::TYPE_INTEGER, |
|
19
|
|
|
Table::TYPE_SMALLINT, |
|
20
|
|
|
]; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var array |
|
24
|
|
|
*/ |
|
25
|
|
|
private $columnTypesWithSize = [ |
|
26
|
|
|
Table::TYPE_TEXT, |
|
27
|
|
|
]; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
private $name; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
private $type; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var bool |
|
41
|
|
|
*/ |
|
42
|
|
|
private $unsigned; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var mixed |
|
46
|
|
|
*/ |
|
47
|
|
|
private $default; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var bool |
|
51
|
|
|
*/ |
|
52
|
|
|
private $identity; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var bool |
|
56
|
|
|
*/ |
|
57
|
|
|
private $primary; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var int |
|
61
|
|
|
*/ |
|
62
|
|
|
private $size; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @var string |
|
66
|
|
|
*/ |
|
67
|
|
|
private $comment; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @var bool |
|
71
|
|
|
*/ |
|
72
|
|
|
private $nullable; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return string |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getName() |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->name; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param string $name |
|
84
|
|
|
*/ |
|
85
|
|
|
public function setName($name) |
|
86
|
|
|
{ |
|
87
|
|
|
$this->name = $name; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @return string |
|
92
|
|
|
*/ |
|
93
|
|
|
public function getType() |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->type; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @param string $type |
|
100
|
|
|
*/ |
|
101
|
|
|
public function setType($type) |
|
102
|
|
|
{ |
|
103
|
|
|
$this->type = $type; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return null |
|
|
|
|
|
|
108
|
|
|
*/ |
|
109
|
|
|
public function getUnsigned() |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->unsigned; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param null $unsigned |
|
116
|
|
|
*/ |
|
117
|
|
|
public function setUnsigned($unsigned) |
|
118
|
|
|
{ |
|
119
|
|
|
$this->unsigned = $unsigned; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @return null |
|
124
|
|
|
*/ |
|
125
|
|
|
public function getDefault() |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->default; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param null $default |
|
132
|
|
|
*/ |
|
133
|
|
|
public function setDefault($default) |
|
134
|
|
|
{ |
|
135
|
|
|
$this->default = $default; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @return null |
|
|
|
|
|
|
140
|
|
|
*/ |
|
141
|
|
|
public function getIdentity() |
|
142
|
|
|
{ |
|
143
|
|
|
return $this->identity; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @param null $identity |
|
148
|
|
|
*/ |
|
149
|
|
|
public function setIdentity($identity) |
|
150
|
|
|
{ |
|
151
|
|
|
$this->identity = $identity; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @return null |
|
|
|
|
|
|
156
|
|
|
*/ |
|
157
|
|
|
public function getPrimary() |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->primary; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @param null $primary |
|
164
|
|
|
*/ |
|
165
|
|
|
public function setPrimary($primary) |
|
166
|
|
|
{ |
|
167
|
|
|
$this->primary = $primary; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @return int |
|
172
|
|
|
*/ |
|
173
|
|
|
public function getSize() |
|
174
|
|
|
{ |
|
175
|
|
|
return $this->size; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @param int $size |
|
180
|
|
|
*/ |
|
181
|
|
|
public function setSize($size) |
|
182
|
|
|
{ |
|
183
|
|
|
$this->size = $size; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @return string |
|
188
|
|
|
*/ |
|
189
|
|
|
public function getComment() |
|
190
|
|
|
{ |
|
191
|
|
|
return $this->comment; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @param string $comment |
|
196
|
|
|
*/ |
|
197
|
|
|
public function setComment($comment) |
|
198
|
|
|
{ |
|
199
|
|
|
$this->comment = $comment; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* @return boolean |
|
204
|
|
|
*/ |
|
205
|
|
|
public function isNullable() |
|
206
|
|
|
{ |
|
207
|
|
|
return $this->nullable; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* @param boolean $nullable |
|
212
|
|
|
*/ |
|
213
|
|
|
public function setNullable($nullable) |
|
214
|
|
|
{ |
|
215
|
|
|
$this->nullable = $nullable; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* @return bool |
|
220
|
|
|
*/ |
|
221
|
|
|
public function isIntType() |
|
222
|
|
|
{ |
|
223
|
|
|
return in_array($this->getType(), $this->intTypes); |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* @return bool |
|
228
|
|
|
*/ |
|
229
|
|
|
public function isTypeWithSize() |
|
230
|
|
|
{ |
|
231
|
|
|
return in_array($this->getType(), $this->columnTypesWithSize); |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
/** |
|
235
|
|
|
* @return array |
|
|
|
|
|
|
236
|
|
|
*/ |
|
237
|
|
|
public function getDefinitionArray() |
|
238
|
|
|
{ |
|
239
|
|
|
// @TODO |
|
240
|
|
|
} |
|
241
|
|
|
} |
|
242
|
|
|
|
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.