88class Column
99{
1010
11- /** @var Table|null */
12- private $ table ;
11+ private ?Table $ table = null ;
1312
14- /** @var string */
15- private $ name ;
13+ private ?string $ name = null ;
1614
17- /** @var mixed */
18- private $ type ;
15+ private ?string $ type = null ;
1916
20- /** @var mixed */
21- private $ subtype ;
17+ private ?string $ subtype = null ;
2218
23- /** @var bool */
24- private $ nullable ;
19+ private ?bool $ nullable = null ;
2520
26- /** @var mixed */
27- private $ default ;
21+ private ?string $ default = null ;
2822
2923 /** @var string[] */
30- private $ enum = [];
24+ private array $ enum = [];
3125
32- /** @var bool */
33- private $ onUpdate ;
26+ private bool $ onUpdate ;
3427
35- /** @var PhpDoc|null */
36- private $ phpDoc ;
28+ private ?PhpDoc $ phpDoc = null ;
3729
38- /** @var bool|null */
39- private $ primary ;
30+ private ?bool $ primary = null ;
4031
41- /** @var bool */
42- private $ unique ;
32+ private bool $ unique ;
4333
44- /** @var bool */
45- private $ index ;
34+ private bool $ index ;
4635
47- /** @var ForeignKey */
48- private $ foreignKey ;
36+ private ForeignKey $ foreignKey ;
4937
5038 public function attach (Table $ table ): void
5139 {
52- if ($ this ->table ) {
40+ if ($ this ->table !== null ) {
5341 throw new InvalidAttachException ('Column is already attached to table. ' );
5442 }
5543
@@ -58,7 +46,7 @@ public function attach(Table $table): void
5846
5947 public function getTable (): Table
6048 {
61- if (! $ this ->table ) {
49+ if ($ this ->table === null ) {
6250 throw new LogicException ('Table is needed ' );
6351 }
6452
@@ -67,6 +55,10 @@ public function getTable(): Table
6755
6856 public function getName (): string
6957 {
58+ if ($ this ->name === null ) {
59+ throw new LogicException ('Name is needed ' );
60+ }
61+
7062 return $ this ->name ;
7163 }
7264
@@ -75,39 +67,35 @@ public function setName(string $name): void
7567 $ this ->name = $ name ;
7668 }
7769
78- /**
79- * @return mixed
80- */
81- public function getType ()
70+ public function getType (): string
8271 {
72+ if ($ this ->type === null ) {
73+ throw new LogicException ('Type is needed ' );
74+ }
75+
8376 return $ this ->type ;
8477 }
8578
86- /**
87- * @param mixed $type
88- */
89- public function setType ($ type ): void
79+ public function setType (string $ type ): void
9080 {
9181 $ this ->type = $ type ;
9282 }
9383
94- /**
95- * @return mixed
96- */
97- public function getSubtype ()
84+ public function getSubtype (): string
9885 {
86+ if ($ this ->subtype === null ) {
87+ throw new LogicException ('Subtype is needed ' );
88+ }
89+
9990 return $ this ->subtype ;
10091 }
10192
102- /**
103- * @param mixed $subtype
104- */
105- public function setSubtype ($ subtype ): void
93+ public function setSubtype (string $ subtype ): void
10694 {
10795 $ this ->subtype = $ subtype ;
10896 }
10997
110- public function isNullable (): bool
98+ public function isNullable (): ? bool
11199 {
112100 return $ this ->nullable ;
113101 }
@@ -117,18 +105,12 @@ public function setNullable(bool $nullable): void
117105 $ this ->nullable = $ nullable ;
118106 }
119107
120- /**
121- * @return mixed
122- */
123- public function getDefault ()
108+ public function getDefault (): ?string
124109 {
125110 return $ this ->default ;
126111 }
127112
128- /**
129- * @param mixed $default
130- */
131- public function setDefault ($ default ): void
113+ public function setDefault (string $ default ): void
132114 {
133115 $ this ->default = $ default ;
134116 }
@@ -161,7 +143,7 @@ public function setOnUpdate(bool $onUpdate): void
161143
162144 public function getPhpDoc (): PhpDoc
163145 {
164- if (! $ this ->phpDoc ) {
146+ if ($ this ->phpDoc === null ) {
165147 $ this ->phpDoc = new PhpDoc ();
166148 }
167149
0 commit comments