|
9 | 9 | class ModelLexer implements Lexer |
10 | 10 | { |
11 | 11 | private static $dataTypes = [ |
12 | | - 'bigIncrements', |
13 | | - 'bigInteger', |
14 | | - 'binary', |
15 | | - 'boolean', |
16 | | - 'char', |
17 | | - 'date', |
18 | | - 'dateTime', |
19 | | - 'dateTimeTz', |
20 | | - 'decimal', |
21 | | - 'double', |
22 | | - 'enum', |
23 | | - 'float', |
24 | | - 'geometry', |
25 | | - 'geometryCollection', |
26 | | - 'increments', |
27 | | - 'integer', |
28 | | - 'ipAddress', |
29 | | - 'json', |
30 | | - 'jsonb', |
31 | | - 'lineString', |
32 | | - 'longText', |
33 | | - 'macAddress', |
34 | | - 'mediumIncrements', |
35 | | - 'mediumInteger', |
36 | | - 'mediumText', |
37 | | - 'morphs', |
38 | | - 'uuidMorphs', |
39 | | - 'multiLineString', |
40 | | - 'multiPoint', |
41 | | - 'multiPolygon', |
42 | | - 'nullableMorphs', |
43 | | - 'nullableUuidMorphs', |
44 | | - 'nullableTimestamps', |
45 | | - 'point', |
46 | | - 'polygon', |
47 | | - 'rememberToken', |
48 | | - 'set', |
49 | | - 'smallIncrements', |
50 | | - 'smallInteger', |
51 | | - 'softDeletes', |
52 | | - 'softDeletesTz', |
53 | | - 'string', |
54 | | - 'text', |
55 | | - 'time', |
56 | | - 'timeTz', |
57 | | - 'timestamp', |
58 | | - 'timestampTz', |
59 | | - 'timestamps', |
60 | | - 'timestampsTz', |
61 | | - 'tinyIncrements', |
62 | | - 'tinyInteger', |
63 | | - 'unsignedBigInteger', |
64 | | - 'unsignedDecimal', |
65 | | - 'unsignedInteger', |
66 | | - 'unsignedMediumInteger', |
67 | | - 'unsignedSmallInteger', |
68 | | - 'unsignedTinyInteger', |
69 | | - 'uuid', |
70 | | - 'year' |
| 12 | + 'bigincrements' => 'bigIncrements', |
| 13 | + 'biginteger' => 'bigInteger', |
| 14 | + 'binary' => 'binary', |
| 15 | + 'boolean' => 'boolean', |
| 16 | + 'char' => 'char', |
| 17 | + 'date' => 'date', |
| 18 | + 'datetime' => 'dateTime', |
| 19 | + 'datetimetz' => 'dateTimeTz', |
| 20 | + 'decimal' => 'decimal', |
| 21 | + 'double' => 'double', |
| 22 | + 'enum' => 'enum', |
| 23 | + 'float' => 'float', |
| 24 | + 'geometry' => 'geometry', |
| 25 | + 'geometrycollection' => 'geometryCollection', |
| 26 | + 'increments' => 'increments', |
| 27 | + 'integer' => 'integer', |
| 28 | + 'ipaddress' => 'ipAddress', |
| 29 | + 'json' => 'json', |
| 30 | + 'jsonb' => 'jsonb', |
| 31 | + 'linestring' => 'lineString', |
| 32 | + 'longtext' => 'longText', |
| 33 | + 'macaddress' => 'macAddress', |
| 34 | + 'mediumincrements' => 'mediumIncrements', |
| 35 | + 'mediuminteger' => 'mediumInteger', |
| 36 | + 'mediumtext' => 'mediumText', |
| 37 | + 'morphs' => 'morphs', |
| 38 | + 'uuidmorphs' => 'uuidMorphs', |
| 39 | + 'multilinestring' => 'multiLineString', |
| 40 | + 'multipoint' => 'multiPoint', |
| 41 | + 'multipolygon' => 'multiPolygon', |
| 42 | + 'nullablemorphs' => 'nullableMorphs', |
| 43 | + 'nullableuuidmorphs' => 'nullableUuidMorphs', |
| 44 | + 'nullabletimestamps' => 'nullableTimestamps', |
| 45 | + 'point' => 'point', |
| 46 | + 'polygon' => 'polygon', |
| 47 | + 'remembertoken' => 'rememberToken', |
| 48 | + 'set' => 'set', |
| 49 | + 'smallincrements' => 'smallIncrements', |
| 50 | + 'smallinteger' => 'smallInteger', |
| 51 | + 'softdeletes' => 'softDeletes', |
| 52 | + 'softdeletestz' => 'softDeletesTz', |
| 53 | + 'string' => 'string', |
| 54 | + 'text' => 'text', |
| 55 | + 'time' => 'time', |
| 56 | + 'timetz' => 'timeTz', |
| 57 | + 'timestamp' => 'timestamp', |
| 58 | + 'timestamptz' => 'timestampTz', |
| 59 | + 'timestamps' => 'timestamps', |
| 60 | + 'timestampstz' => 'timestampsTz', |
| 61 | + 'tinyincrements' => 'tinyIncrements', |
| 62 | + 'tinyinteger' => 'tinyInteger', |
| 63 | + 'unsignedbiginteger' => 'unsignedBigInteger', |
| 64 | + 'unsigneddecimal' => 'unsignedDecimal', |
| 65 | + 'unsignedinteger' => 'unsignedInteger', |
| 66 | + 'unsignedmediuminteger' => 'unsignedMediumInteger', |
| 67 | + 'unsignedsmallinteger' => 'unsignedSmallInteger', |
| 68 | + 'unsignedtinyinteger' => 'unsignedTinyInteger', |
| 69 | + 'uuid' => 'uuid', |
| 70 | + 'year' => 'year', |
71 | 71 | ]; |
72 | 72 |
|
73 | 73 | private static $modifiers = [ |
74 | | - 'autoIncrement', |
75 | | - 'charset', |
76 | | - 'collation', |
77 | | - 'default', |
78 | | - 'nullable', |
79 | | - 'unsigned', |
80 | | - 'useCurrent', |
81 | | - 'always' |
| 74 | + 'autoincrement' => 'autoIncrement', |
| 75 | + 'charset' => 'charset', |
| 76 | + 'collation' => 'collation', |
| 77 | + 'default' => 'default', |
| 78 | + 'nullable' => 'nullable', |
| 79 | + 'unsigned' => 'unsigned', |
| 80 | + 'usecurrent' => 'useCurrent', |
| 81 | + 'always' => 'always', |
82 | 82 | ]; |
83 | 83 |
|
84 | 84 | public function analyze(array $tokens): array |
@@ -136,18 +136,18 @@ private function buildColumn(string $name, string $definition) |
136 | 136 |
|
137 | 137 | if ($value === 'id') { |
138 | 138 | $data_type = 'id'; |
139 | | - } elseif (in_array($value, self::$dataTypes)) { |
140 | | - $data_type = $value; |
| 139 | + } elseif (isset(self::$dataTypes[strtolower($value)])) { |
| 140 | + $data_type = self::$dataTypes[strtolower($value)]; |
141 | 141 | if (!empty($attributes)) { |
142 | 142 | $attributes = explode(',', $attributes); |
143 | 143 | } |
144 | 144 | } |
145 | 145 |
|
146 | | - if (in_array($value, self::$modifiers)) { |
| 146 | + if (isset(self::$modifiers[strtolower($value)])) { |
147 | 147 | if (empty($attributes)) { |
148 | | - $modifiers[] = $value; |
| 148 | + $modifiers[] = self::$modifiers[strtolower($value)]; |
149 | 149 | } else { |
150 | | - $modifiers[] = [$value => $attributes]; |
| 150 | + $modifiers[] = [self::$modifiers[strtolower($value)] => $attributes]; |
151 | 151 | $attributes = []; |
152 | 152 | } |
153 | 153 | } |
|
0 commit comments