Complex classes like SQLiteAdapter often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SQLiteAdapter, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
31 | class SQLiteAdapter extends PdoAdapter |
||
32 | { |
||
33 | public const MEMORY = ':memory:'; |
||
34 | |||
35 | /** |
||
36 | * List of supported Phinx column types with their SQL equivalents |
||
37 | * some types have an affinity appended to ensure they do not receive NUMERIC affinity |
||
38 | * |
||
39 | * @var string[] |
||
40 | */ |
||
41 | protected static $supportedColumnTypes = [ |
||
42 | self::PHINX_TYPE_BIG_INTEGER => 'biginteger', |
||
43 | self::PHINX_TYPE_BINARY => 'binary_blob', |
||
44 | self::PHINX_TYPE_BINARYUUID => 'binary_blob', |
||
45 | self::PHINX_TYPE_BLOB => 'blob', |
||
46 | self::PHINX_TYPE_BOOLEAN => 'boolean_integer', |
||
47 | self::PHINX_TYPE_CHAR => 'char', |
||
48 | self::PHINX_TYPE_DATE => 'date_text', |
||
49 | self::PHINX_TYPE_DATETIME => 'datetime_text', |
||
50 | self::PHINX_TYPE_DECIMAL => 'decimal', |
||
51 | self::PHINX_TYPE_DOUBLE => 'double', |
||
52 | self::PHINX_TYPE_FLOAT => 'float', |
||
53 | self::PHINX_TYPE_INTEGER => 'integer', |
||
54 | self::PHINX_TYPE_JSON => 'json_text', |
||
55 | self::PHINX_TYPE_JSONB => 'jsonb_text', |
||
56 | 42 | self::PHINX_TYPE_SMALL_INTEGER => 'smallinteger', |
|
57 | self::PHINX_TYPE_STRING => 'varchar', |
||
58 | 42 | self::PHINX_TYPE_TEXT => 'text', |
|
59 | 42 | self::PHINX_TYPE_TIME => 'time_text', |
|
60 | self::PHINX_TYPE_TIMESTAMP => 'timestamp_text', |
||
61 | self::PHINX_TYPE_TINY_INTEGER => 'tinyinteger', |
||
62 | self::PHINX_TYPE_UUID => 'uuid_text', |
||
63 | self::PHINX_TYPE_VARBINARY => 'varbinary_blob', |
||
64 | ]; |
||
65 | 42 | ||
66 | 42 | /** |
|
67 | * List of aliases of supported column types |
||
68 | * |
||
69 | 42 | * @var string[] |
|
70 | */ |
||
71 | protected static $supportedColumnTypeAliases = [ |
||
72 | 42 | 'varchar' => self::PHINX_TYPE_STRING, |
|
73 | 42 | 'tinyint' => self::PHINX_TYPE_TINY_INTEGER, |
|
74 | 42 | 'tinyinteger' => self::PHINX_TYPE_TINY_INTEGER, |
|
75 | 42 | 'smallint' => self::PHINX_TYPE_SMALL_INTEGER, |
|
76 | 'int' => self::PHINX_TYPE_INTEGER, |
||
77 | 'mediumint' => self::PHINX_TYPE_INTEGER, |
||
78 | 'mediuminteger' => self::PHINX_TYPE_INTEGER, |
||
79 | 42 | 'bigint' => self::PHINX_TYPE_BIG_INTEGER, |
|
80 | 42 | 'tinytext' => self::PHINX_TYPE_TEXT, |
|
81 | 'mediumtext' => self::PHINX_TYPE_TEXT, |
||
82 | 'longtext' => self::PHINX_TYPE_TEXT, |
||
83 | 'tinyblob' => self::PHINX_TYPE_BLOB, |
||
84 | 'mediumblob' => self::PHINX_TYPE_BLOB, |
||
85 | 'longblob' => self::PHINX_TYPE_BLOB, |
||
86 | 'real' => self::PHINX_TYPE_FLOAT, |
||
87 | 42 | ]; |
|
88 | 42 | ||
89 | 42 | /** |
|
90 | * List of known but unsupported Phinx column types |
||
91 | * |
||
92 | * @var string[] |
||
93 | */ |
||
94 | 48 | protected static $unsupportedColumnTypes = [ |
|
95 | self::PHINX_TYPE_BIT, |
||
96 | 48 | self::PHINX_TYPE_CIDR, |
|
97 | 48 | self::PHINX_TYPE_DECIMAL, |
|
98 | self::PHINX_TYPE_ENUM, |
||
99 | self::PHINX_TYPE_FILESTREAM, |
||
100 | self::PHINX_TYPE_GEOMETRY, |
||
101 | self::PHINX_TYPE_INET, |
||
102 | self::PHINX_TYPE_INTERVAL, |
||
103 | self::PHINX_TYPE_LINESTRING, |
||
104 | self::PHINX_TYPE_MACADDR, |
||
105 | self::PHINX_TYPE_POINT, |
||
106 | self::PHINX_TYPE_POLYGON, |
||
107 | self::PHINX_TYPE_SET, |
||
108 | ]; |
||
109 | |||
110 | 1 | /** |
|
111 | * @var string[] |
||
112 | 1 | */ |
|
113 | 1 | protected $definitionsWithLimits = [ |
|
114 | 'CHAR', |
||
115 | 'CHARACTER', |
||
116 | 'VARCHAR', |
||
117 | 'VARYING CHARACTER', |
||
118 | 'NCHAR', |
||
119 | 'NATIVE CHARACTER', |
||
120 | 'NVARCHAR', |
||
121 | ]; |
||
122 | |||
123 | protected $suffix = '.sqlite3'; |
||
124 | |||
125 | /** |
||
126 | * Indicates whether the database library version is at least the specified version |
||
127 | * |
||
128 | * @param string $ver The version to check against e.g. '3.28.0' |
||
129 | * |
||
130 | * @return bool |
||
131 | */ |
||
132 | public function databaseVersionAtLeast($ver) |
||
133 | { |
||
134 | 43 | $actual = $this->query('SELECT sqlite_version()')->fetchColumn(); |
|
135 | |||
136 | 43 | return version_compare($actual, $ver, '>='); |
|
137 | } |
||
138 | |||
139 | /** |
||
140 | * {@inheritDoc} |
||
141 | * |
||
142 | 44 | * @throws \RuntimeException |
|
143 | * @throws \InvalidArgumentException |
||
144 | 44 | * |
|
145 | * @return void |
||
146 | */ |
||
147 | public function connect() |
||
148 | { |
||
149 | if ($this->connection === null) { |
||
150 | 42 | if (!class_exists('PDO') || !in_array('sqlite', PDO::getAvailableDrivers(), true)) { |
|
151 | // @codeCoverageIgnoreStart |
||
152 | 42 | throw new RuntimeException('You need to enable the PDO_SQLITE extension for Phinx to run properly.'); |
|
153 | 42 | // @codeCoverageIgnoreEnd |
|
154 | 42 | } |
|
155 | 12 | ||
156 | 42 | $options = $this->getOptions(); |
|
157 | |||
158 | 42 | // use a memory database if the option was specified |
|
159 | if (!empty($options['memory']) || $options['name'] === static::MEMORY) { |
||
160 | $dsn = 'sqlite:' . static::MEMORY; |
||
161 | } else { |
||
162 | $dsn = 'sqlite:' . $options['name'] . $this->suffix; |
||
163 | } |
||
164 | 42 | ||
165 | $driverOptions = []; |
||
166 | |||
167 | 42 | // use custom data fetch mode |
|
168 | 42 | if (!empty($options['fetch_mode'])) { |
|
169 | 42 | $driverOptions[PDO::ATTR_DEFAULT_FETCH_MODE] = constant('\PDO::FETCH_' . strtoupper($options['fetch_mode'])); |
|
170 | 35 | } |
|
171 | 35 | ||
172 | 35 | $db = $this->createPdoConnection($dsn, null, null, $driverOptions); |
|
173 | 35 | ||
174 | $this->setConnection($db); |
||
175 | 35 | } |
|
176 | 42 | } |
|
177 | |||
178 | 1 | /** |
|
179 | 1 | * @inheritDoc |
|
180 | 1 | */ |
|
181 | 1 | public function setOptions(array $options) |
|
182 | { |
||
183 | 1 | parent::setOptions($options); |
|
184 | 1 | ||
185 | if (isset($options['suffix'])) { |
||
186 | $this->suffix = $options['suffix']; |
||
187 | 42 | } |
|
188 | 42 | //don't "fix" the file extension if it is blank, some people |
|
189 | 42 | //might want a SQLITE db file with absolutely no extension. |
|
190 | 42 | if ($this->suffix !== '' && strpos($this->suffix, '.') !== 0) { |
|
191 | 42 | $this->suffix = '.' . $this->suffix; |
|
192 | } |
||
193 | |||
194 | 42 | return $this; |
|
195 | 42 | } |
|
196 | 42 | ||
197 | 42 | /** |
|
198 | 42 | * @inheritDoc |
|
199 | 42 | */ |
|
200 | public function disconnect() |
||
201 | { |
||
202 | 1 | $this->connection = null; |
|
203 | 1 | } |
|
204 | 1 | ||
205 | /** |
||
206 | 1 | * @inheritDoc |
|
207 | 1 | */ |
|
208 | 1 | public function hasTransactions() |
|
209 | 1 | { |
|
210 | 1 | return true; |
|
211 | 1 | } |
|
212 | 42 | ||
213 | 42 | /** |
|
214 | 37 | * @inheritDoc |
|
215 | */ |
||
216 | public function beginTransaction() |
||
220 | 1 | ||
221 | 1 | /** |
|
222 | 1 | * @inheritDoc |
|
223 | 1 | */ |
|
224 | public function commitTransaction() |
||
225 | 42 | { |
|
228 | |||
229 | 42 | /** |
|
230 | 6 | * @inheritDoc |
|
231 | 42 | */ |
|
232 | 42 | public function rollbackTransaction() |
|
236 | |||
237 | 1 | /** |
|
238 | * @inheritDoc |
||
239 | 1 | */ |
|
240 | 1 | public function quoteTableName($tableName) |
|
244 | |||
245 | 1 | /** |
|
246 | * @inheritDoc |
||
247 | 1 | */ |
|
248 | 1 | public function quoteColumnName($columnName) |
|
252 | |||
253 | 1 | /** |
|
254 | * @param string $tableName Table name |
||
255 | 1 | * @param bool $quoted Whether to return the schema name and table name escaped and quoted. If quoted, the schema (if any) will also be appended with a dot |
|
256 | 1 | * |
|
257 | 1 | * @return array |
|
258 | 1 | */ |
|
259 | protected function getSchemaName($tableName, $quoted = false) |
||
276 | 1 | ||
277 | /** |
||
278 | 1 | * Retrieves information about a given table from one of the SQLite pragmas |
|
279 | 1 | * |
|
280 | 1 | * @param string $tableName The table to query |
|
281 | * @param string $pragma The pragma to query |
||
282 | 1 | * |
|
283 | 1 | * @return array |
|
284 | 1 | */ |
|
285 | protected function getTableInfo($tableName, $pragma = 'table_info') |
||
291 | |||
292 | /** |
||
293 | * Searches through all available schemata to find a table and returns an array |
||
294 | * containing the bare schema name and whether the table exists at all. |
||
295 | 8 | * If no schema was specified and the table does not exist the "main" schema is returned |
|
296 | * |
||
297 | 8 | * @param string $tableName The name of the table to find |
|
298 | 8 | * |
|
299 | 8 | * @return array |
|
300 | 7 | */ |
|
301 | protected function resolveTable($tableName) |
||
346 | 2 | ||
347 | /** |
||
348 | 2 | * @inheritDoc |
|
349 | 1 | */ |
|
350 | public function hasTable($tableName) |
||
354 | 1 | ||
355 | /** |
||
356 | 1 | * @inheritDoc |
|
357 | 1 | */ |
|
358 | 1 | public function createTable(Table $table, array $columns = [], array $indexes = []) |
|
420 | 6 | ||
421 | /** |
||
422 | 6 | * {@inheritDoc} |
|
423 | 6 | * |
|
424 | 6 | * @throws \InvalidArgumentException |
|
425 | 6 | */ |
|
426 | 6 | protected function getChangePrimaryKeyInstructions(Table $table, $newColumns) |
|
455 | 2 | ||
456 | 2 | /** |
|
457 | 2 | * @inheritDoc |
|
458 | 2 | * |
|
459 | 2 | * SQLiteAdapter does not implement this functionality, and so will always throw an exception if used. |
|
460 | * |
||
461 | 2 | * @throws \BadMethodCallException |
|
462 | */ |
||
463 | 2 | protected function getChangeCommentInstructions(Table $table, $newComment) |
|
467 | |||
468 | /** |
||
469 | 2 | * @inheritDoc |
|
470 | */ |
||
471 | 2 | protected function getRenameTableInstructions($tableName, $newTableName) |
|
482 | |||
483 | 2 | /** |
|
484 | 2 | * @inheritDoc |
|
485 | 2 | */ |
|
486 | 2 | protected function getDropTableInstructions($tableName) |
|
493 | 2 | ||
494 | /** |
||
495 | * @inheritDoc |
||
496 | */ |
||
497 | public function truncateTable($tableName) |
||
498 | { |
||
499 | $info = $this->resolveTable($tableName); |
||
500 | // first try deleting the rows |
||
501 | 9 | $this->execute(sprintf( |
|
502 | 'DELETE FROM %s.%s', |
||
503 | 9 | $this->quoteColumnName($info['schema']), |
|
504 | 9 | $this->quoteColumnName($info['table']) |
|
505 | )); |
||
506 | 9 | ||
507 | 9 | // assuming no error occurred, reset the autoincrement (if any) |
|
508 | 9 | if ($this->hasTable($info['schema'] . '.sqlite_sequence')) { |
|
509 | 9 | $this->execute(sprintf( |
|
510 | 9 | 'DELETE FROM %s.%s where name = %s', |
|
511 | 9 | $this->quoteColumnName($info['schema']), |
|
512 | 9 | 'sqlite_sequence', |
|
513 | 9 | $this->quoteString($info['table']) |
|
514 | 9 | )); |
|
515 | 9 | } |
|
516 | } |
||
517 | |||
518 | /** |
||
519 | * Parses a default-value expression to yield either a Literal representing |
||
520 | * a string value, a string representing an expression, or some other scalar |
||
521 | 9 | * |
|
522 | * @param mixed $v The default-value expression to interpret |
||
523 | 9 | * @param string $t The Phinx type of the column |
|
524 | 4 | * |
|
525 | 4 | * @return mixed |
|
526 | */ |
||
527 | 9 | protected function parseDefaultValue($v, $t) |
|
590 | 1 | ||
591 | 1 | /** |
|
592 | 1 | * Returns the name of the specified table's identity column, or null if the table has no identity |
|
593 | 1 | * |
|
594 | 1 | * The process of finding an identity column is somewhat convoluted as SQLite has no direct way of querying whether a given column is an alias for the table's row ID |
|
595 | 1 | * |
|
596 | 1 | * @param string $tableName The name of the table |
|
597 | 1 | * |
|
598 | * @return string|null |
||
599 | */ |
||
600 | protected function resolveIdentity($tableName) |
||
634 | 5 | ||
635 | /** |
||
636 | 1 | * @inheritDoc |
|
637 | */ |
||
638 | public function getColumns($tableName) |
||
663 | 5 | ||
664 | 5 | /** |
|
665 | 5 | * @inheritDoc |
|
666 | 5 | */ |
|
667 | 5 | public function hasColumn($tableName, $columnName) |
|
678 | |||
679 | 4 | /** |
|
680 | * @inheritDoc |
||
681 | */ |
||
682 | 4 | protected function getAddColumnInstructions(Table $table, Column $column) |
|
720 | 1 | ||
721 | /** |
||
722 | * Returns the original CREATE statement for the give table |
||
723 | 1 | * |
|
724 | * @param string $tableName The table name to get the create statement for |
||
725 | * |
||
726 | * @return string |
||
727 | 1 | */ |
|
728 | protected function getDeclaringSql($tableName) |
||
741 | 1 | ||
742 | 1 | /** |
|
743 | 1 | * Returns the original CREATE statement for the give index |
|
744 | 1 | * |
|
745 | * @param string $tableName The table name to get the create statement for |
||
746 | 1 | * @return string |
|
747 | */ |
||
748 | 1 | protected function getDeclaringIndexSql($tableName, $indexName) |
|
761 | 1 | ||
762 | 1 | /** |
|
763 | * Copies all the data from a tmp table to another table |
||
764 | 1 | * |
|
765 | * @param string $tableName The table name to copy the data to |
||
766 | 1 | * @param string $tmpTableName The tmp table name where the data is stored |
|
767 | 1 | * @param string[] $writeColumns The list of columns in the target table |
|
768 | 1 | * @param string[] $selectColumns The list of columns in the tmp table |
|
769 | 1 | * |
|
770 | 1 | * @return void |
|
771 | */ |
||
772 | 1 | protected function copyDataToNewTable($tableName, $tmpTableName, $writeColumns, $selectColumns) |
|
783 | |||
784 | /** |
||
785 | * Modifies the passed instructions to copy all data from the table into |
||
786 | * the provided tmp table and then drops the table and rename tmp table. |
||
787 | * |
||
788 | * @param \Phinx\Db\Util\AlterInstructions $instructions The instructions to modify |
||
789 | * @param string $tableName The table name to copy the data to |
||
790 | * |
||
791 | * @return \Phinx\Db\Util\AlterInstructions |
||
792 | */ |
||
793 | protected function copyAndDropTmpTable($instructions, $tableName) |
||
815 | |||
816 | 43 | /** |
|
817 | * Returns the columns and type to use when copying a table to another in the process |
||
818 | * of altering a table |
||
819 | 43 | * |
|
820 | 1 | * @param string $tableName The table to modify |
|
821 | * @param string|false $columnName The column name that is about to change |
||
822 | 43 | * @param string|false $newColumnName Optionally the new name for the column |
|
823 | 38 | * |
|
824 | * @throws \InvalidArgumentException |
||
825 | 43 | * |
|
826 | 42 | * @return array |
|
827 | */ |
||
828 | 43 | protected function calculateNewTableColumns($tableName, $columnName, $newColumnName) |
|
864 | 1 | ||
865 | /** |
||
866 | * Returns the initial instructions to alter a table using the |
||
867 | 1 | * create-copy-drop strategy |
|
868 | * |
||
869 | 1 | * @param string $tableName The table to modify |
|
870 | 1 | * |
|
871 | 1 | * @return \Phinx\Db\Util\AlterInstructions |
|
872 | */ |
||
873 | protected function beginAlterByCopyTable($tableName) |
||
900 | 1 | ||
901 | 2 | /** |
|
902 | * @inheritDoc |
||
903 | */ |
||
904 | protected function getRenameColumnInstructions($tableName, $columnName, $newColumnName) |
||
927 | |||
928 | /** |
||
929 | * @inheritDoc |
||
930 | */ |
||
931 | protected function getChangeColumnInstructions($tableName, $columnName, Column $newColumn) |
||
956 | 2 | ||
957 | /** |
||
958 | * @inheritDoc |
||
959 | */ |
||
960 | protected function getDropColumnInstructions($tableName, $columnName) |
||
988 | |||
989 | /** |
||
990 | * Get an array of indexes from a particular table. |
||
991 | 42 | * |
|
992 | * @param string $tableName Table name |
||
993 | 42 | * |
|
994 | 42 | * @return array |
|
995 | 42 | */ |
|
996 | 42 | protected function getIndexes($tableName) |
|
1013 | 42 | ||
1014 | /** |
||
1015 | * Finds the names of a table's indexes matching the supplied columns |
||
1016 | * |
||
1017 | 42 | * @param string $tableName The table to which the index belongs |
|
1018 | * @param string|string[] $columns The columns of the index |
||
1019 | 42 | * |
|
1020 | * @return array |
||
1021 | */ |
||
1022 | protected function resolveIndex($tableName, $columns) |
||
1037 | |||
1038 | /** |
||
1039 | * @inheritDoc |
||
1040 | */ |
||
1041 | public function hasIndex($tableName, $columns) |
||
1045 | 2 | ||
1046 | 2 | /** |
|
1047 | 6 | * @inheritDoc |
|
1048 | */ |
||
1049 | 8 | public function hasIndexByName($tableName, $indexName) |
|
1062 | |||
1063 | /** |
||
1064 | * @inheritDoc |
||
1065 | 47 | */ |
|
1066 | protected function getAddIndexInstructions(Table $table, Index $index) |
||
1082 | 5 | ||
1083 | 5 | /** |
|
1084 | 5 | * @inheritDoc |
|
1085 | 5 | */ |
|
1086 | 5 | protected function getDropIndexByColumnsInstructions($tableName, $columns) |
|
1103 | |||
1104 | /** |
||
1105 | * @inheritDoc |
||
1106 | */ |
||
1107 | protected function getDropIndexByNameInstructions($tableName, $indexName) |
||
1132 | |||
1133 | /** |
||
1134 | * {@inheritDoc} |
||
1135 | * |
||
1136 | * @throws \InvalidArgumentException |
||
1137 | */ |
||
1138 | public function hasPrimaryKey($tableName, $columns, $constraint = null) |
||
1153 | |||
1154 | /** |
||
1155 | * Get the primary key from a particular table. |
||
1156 | * |
||
1157 | * @param string $tableName Table name |
||
1158 | * |
||
1159 | * @return string[] |
||
1160 | */ |
||
1161 | protected function getPrimaryKey($tableName) |
||
1175 | |||
1176 | /** |
||
1177 | * {@inheritDoc} |
||
1178 | * |
||
1179 | * @throws \InvalidArgumentException |
||
1180 | */ |
||
1181 | public function hasForeignKey($tableName, $columns, $constraint = null) |
||
1201 | |||
1202 | /** |
||
1203 | * Get an array of foreign keys from a particular table. |
||
1204 | * |
||
1205 | * @param string $tableName Table name |
||
1206 | * |
||
1207 | * @return array |
||
1208 | */ |
||
1209 | protected function getForeignKeys($tableName) |
||
1224 | |||
1225 | /** |
||
1226 | * @param \Phinx\Db\Table\Table $table The Table |
||
1227 | * @param string $column Column Name |
||
1228 | * |
||
1229 | * @return \Phinx\Db\Util\AlterInstructions |
||
1230 | */ |
||
1231 | protected function getAddPrimaryKeyInstructions(Table $table, $column) |
||
1268 | |||
1269 | /** |
||
1270 | * @param \Phinx\Db\Table\Table $table Table |
||
1271 | * @param string $column Column Name |
||
1272 | * |
||
1273 | * @return \Phinx\Db\Util\AlterInstructions |
||
1274 | */ |
||
1275 | protected function getDropPrimaryKeyInstructions($table, $column) |
||
1298 | |||
1299 | /** |
||
1300 | * @inheritDoc |
||
1301 | */ |
||
1302 | protected function getAddForeignKeyInstructions(Table $table, ForeignKey $foreignKey) |
||
1344 | |||
1345 | /** |
||
1346 | * @inheritDoc |
||
1347 | * |
||
1348 | * SQLiteAdapter does not implement this functionality, and so will always throw an exception if used. |
||
1349 | * |
||
1350 | * @throws \BadMethodCallException |
||
1351 | */ |
||
1352 | protected function getDropForeignKeyInstructions($tableName, $constraint) |
||
1356 | |||
1357 | /** |
||
1358 | * {@inheritDoc} |
||
1359 | * |
||
1360 | * @throws \InvalidArgumentException |
||
1361 | */ |
||
1362 | protected function getDropForeignKeyByColumnsInstructions($tableName, $columns) |
||
1402 | |||
1403 | /** |
||
1404 | * {@inheritDoc} |
||
1405 | * |
||
1406 | * @throws \Phinx\Db\Adapter\UnsupportedColumnTypeException |
||
1407 | */ |
||
1408 | public function getSqlType($type, $limit = null) |
||
1423 | |||
1424 | /** |
||
1425 | * Returns Phinx type by SQL type |
||
1426 | * |
||
1427 | * @param string|null $sqlTypeDef SQL Type definition |
||
1428 | * |
||
1429 | * @return array |
||
1430 | */ |
||
1431 | public function getPhinxType($sqlTypeDef) |
||
1473 | |||
1474 | /** |
||
1475 | * @inheritDoc |
||
1476 | */ |
||
1477 | public function createDatabase($name, $options = []) |
||
1481 | |||
1482 | /** |
||
1483 | * @inheritDoc |
||
1484 | */ |
||
1485 | public function hasDatabase($name) |
||
1489 | |||
1490 | /** |
||
1491 | * @inheritDoc |
||
1492 | */ |
||
1493 | public function dropDatabase($name) |
||
1503 | |||
1504 | /** |
||
1505 | * Gets the SQLite Column Definition for a Column object. |
||
1506 | * |
||
1507 | * @param \Phinx\Db\Table\Column $column Column |
||
1508 | * |
||
1509 | * @return string |
||
1510 | */ |
||
1511 | protected function getColumnSqlDefinition(Column $column) |
||
1539 | |||
1540 | /** |
||
1541 | * Gets the comment Definition for a Column object. |
||
1542 | * |
||
1543 | * @param \Phinx\Db\Table\Column $column Column |
||
1544 | * |
||
1545 | * @return string |
||
1546 | */ |
||
1547 | protected function getCommentDefinition(Column $column) |
||
1555 | |||
1556 | /** |
||
1557 | * Gets the SQLite Index Definition for an Index object. |
||
1558 | * |
||
1559 | * @param \Phinx\Db\Table\Table $table Table |
||
1560 | * @param \Phinx\Db\Table\Index $index Index |
||
1561 | * |
||
1562 | * @return string |
||
1563 | */ |
||
1564 | protected function getIndexSqlDefinition(Table $table, Index $index) |
||
1584 | |||
1585 | /** |
||
1586 | * @inheritDoc |
||
1587 | */ |
||
1588 | public function getColumnTypes() |
||
1589 | { |
||
1590 | return array_keys(static::$supportedColumnTypes); |
||
1591 | } |
||
1592 | |||
1593 | /** |
||
1594 | * Gets the SQLite Foreign Key Definition for an ForeignKey object. |
||
1595 | * |
||
1596 | * @param \Phinx\Db\Table\ForeignKey $foreignKey Foreign key |
||
1597 | * |
||
1598 | * @return string |
||
1599 | */ |
||
1600 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey) |
||
1626 | |||
1627 | /** |
||
1628 | * @inheritDoc |
||
1629 | */ |
||
1630 | public function getDecoratedConnection() |
||
1652 | } |
||
1653 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.