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_DOUBLE => 'double', |
||
| 51 | self::PHINX_TYPE_FLOAT => 'float', |
||
| 52 | self::PHINX_TYPE_INTEGER => 'integer', |
||
| 53 | self::PHINX_TYPE_JSON => 'json_text', |
||
| 54 | self::PHINX_TYPE_JSONB => 'jsonb_text', |
||
| 55 | self::PHINX_TYPE_SMALL_INTEGER => 'smallinteger', |
||
| 56 | 42 | self::PHINX_TYPE_STRING => 'varchar', |
|
| 57 | self::PHINX_TYPE_TEXT => 'text', |
||
| 58 | 42 | self::PHINX_TYPE_TIME => 'time_text', |
|
| 59 | 42 | self::PHINX_TYPE_TIMESTAMP => 'timestamp_text', |
|
| 60 | self::PHINX_TYPE_TINY_INTEGER => 'tinyinteger', |
||
| 61 | self::PHINX_TYPE_UUID => 'uuid_text', |
||
| 62 | self::PHINX_TYPE_VARBINARY => 'varbinary_blob', |
||
| 63 | ]; |
||
| 64 | |||
| 65 | 42 | /** |
|
| 66 | 42 | * List of aliases of supported column types |
|
| 67 | * |
||
| 68 | * @var string[] |
||
| 69 | 42 | */ |
|
| 70 | protected static $supportedColumnTypeAliases = [ |
||
| 71 | 'varchar' => self::PHINX_TYPE_STRING, |
||
| 72 | 42 | 'tinyint' => self::PHINX_TYPE_TINY_INTEGER, |
|
| 73 | 42 | 'tinyinteger' => self::PHINX_TYPE_TINY_INTEGER, |
|
| 74 | 42 | 'smallint' => self::PHINX_TYPE_SMALL_INTEGER, |
|
| 75 | 42 | 'int' => self::PHINX_TYPE_INTEGER, |
|
| 76 | 'mediumint' => self::PHINX_TYPE_INTEGER, |
||
| 77 | 'mediuminteger' => self::PHINX_TYPE_INTEGER, |
||
| 78 | 'bigint' => self::PHINX_TYPE_BIG_INTEGER, |
||
| 79 | 42 | 'tinytext' => self::PHINX_TYPE_TEXT, |
|
| 80 | 42 | 'mediumtext' => self::PHINX_TYPE_TEXT, |
|
| 81 | 'longtext' => self::PHINX_TYPE_TEXT, |
||
| 82 | 'tinyblob' => self::PHINX_TYPE_BLOB, |
||
| 83 | 'mediumblob' => self::PHINX_TYPE_BLOB, |
||
| 84 | 'longblob' => self::PHINX_TYPE_BLOB, |
||
| 85 | 'real' => self::PHINX_TYPE_FLOAT, |
||
| 86 | ]; |
||
| 87 | 42 | ||
| 88 | 42 | /** |
|
| 89 | 42 | * List of known but unsupported Phinx column types |
|
| 90 | * |
||
| 91 | * @var string[] |
||
| 92 | */ |
||
| 93 | protected static $unsupportedColumnTypes = [ |
||
| 94 | 48 | self::PHINX_TYPE_BIT, |
|
| 95 | self::PHINX_TYPE_CIDR, |
||
| 96 | 48 | self::PHINX_TYPE_DECIMAL, |
|
| 97 | 48 | self::PHINX_TYPE_ENUM, |
|
| 98 | self::PHINX_TYPE_FILESTREAM, |
||
| 99 | self::PHINX_TYPE_GEOMETRY, |
||
| 100 | self::PHINX_TYPE_INET, |
||
| 101 | self::PHINX_TYPE_INTERVAL, |
||
| 102 | self::PHINX_TYPE_LINESTRING, |
||
| 103 | self::PHINX_TYPE_MACADDR, |
||
| 104 | self::PHINX_TYPE_POINT, |
||
| 105 | self::PHINX_TYPE_POLYGON, |
||
| 106 | self::PHINX_TYPE_SET, |
||
| 107 | ]; |
||
| 108 | |||
| 109 | /** |
||
| 110 | 1 | * @var string[] |
|
| 111 | */ |
||
| 112 | 1 | protected $definitionsWithLimits = [ |
|
| 113 | 1 | 'CHAR', |
|
| 114 | 'CHARACTER', |
||
| 115 | 'VARCHAR', |
||
| 116 | 'VARYING CHARACTER', |
||
| 117 | 'NCHAR', |
||
| 118 | 'NATIVE CHARACTER', |
||
| 119 | 'NVARCHAR', |
||
| 120 | ]; |
||
| 121 | |||
| 122 | protected $suffix = '.sqlite3'; |
||
| 123 | |||
| 124 | /** |
||
| 125 | * Indicates whether the database library version is at least the specified version |
||
| 126 | * |
||
| 127 | * @param string $ver The version to check against e.g. '3.28.0' |
||
| 128 | * |
||
| 129 | * @return bool |
||
| 130 | */ |
||
| 131 | public function databaseVersionAtLeast($ver) |
||
| 132 | { |
||
| 133 | $actual = $this->query('SELECT sqlite_version()')->fetchColumn(); |
||
| 134 | 43 | ||
| 135 | return version_compare($actual, $ver, '>='); |
||
| 136 | 43 | } |
|
| 137 | |||
| 138 | /** |
||
| 139 | * {@inheritDoc} |
||
| 140 | * |
||
| 141 | * @throws \RuntimeException |
||
| 142 | 44 | * @throws \InvalidArgumentException |
|
| 143 | * |
||
| 144 | 44 | * @return void |
|
| 145 | */ |
||
| 146 | public function connect() |
||
| 147 | { |
||
| 148 | if ($this->connection === null) { |
||
| 149 | if (!class_exists('PDO') || !in_array('sqlite', PDO::getAvailableDrivers(), true)) { |
||
| 150 | 42 | // @codeCoverageIgnoreStart |
|
| 151 | throw new RuntimeException('You need to enable the PDO_SQLITE extension for Phinx to run properly.'); |
||
| 152 | 42 | // @codeCoverageIgnoreEnd |
|
| 153 | 42 | } |
|
| 154 | 42 | ||
| 155 | 12 | $options = $this->getOptions(); |
|
| 156 | 42 | ||
| 157 | // use a memory database if the option was specified |
||
| 158 | 42 | if (!empty($options['memory']) || $options['name'] === static::MEMORY) { |
|
| 159 | $dsn = 'sqlite:' . static::MEMORY; |
||
| 160 | } else { |
||
| 161 | $dsn = 'sqlite:' . $options['name'] . $this->suffix; |
||
| 162 | } |
||
| 163 | |||
| 164 | 42 | $driverOptions = []; |
|
| 165 | |||
| 166 | // use custom data fetch mode |
||
| 167 | 42 | if (!empty($options['fetch_mode'])) { |
|
| 168 | 42 | $driverOptions[PDO::ATTR_DEFAULT_FETCH_MODE] = constant('\PDO::FETCH_' . strtoupper($options['fetch_mode'])); |
|
| 169 | 42 | } |
|
| 170 | 35 | ||
| 171 | 35 | $db = $this->createPdoConnection($dsn, null, null, $driverOptions); |
|
| 172 | 35 | ||
| 173 | 35 | $this->setConnection($db); |
|
| 174 | } |
||
| 175 | 35 | } |
|
| 176 | 42 | ||
| 177 | /** |
||
| 178 | 1 | * @inheritDoc |
|
| 179 | 1 | */ |
|
| 180 | 1 | public function setOptions(array $options) |
|
| 181 | 1 | { |
|
| 182 | parent::setOptions($options); |
||
| 183 | 1 | ||
| 184 | 1 | if (isset($options['suffix'])) { |
|
| 185 | $this->suffix = $options['suffix']; |
||
| 186 | } |
||
| 187 | 42 | //don't "fix" the file extension if it is blank, some people |
|
| 188 | 42 | //might want a SQLITE db file with absolutely no extension. |
|
| 189 | 42 | if ($this->suffix !== '' && strpos($this->suffix, '.') !== 0) { |
|
| 190 | 42 | $this->suffix = '.' . $this->suffix; |
|
| 191 | 42 | } |
|
| 192 | |||
| 193 | return $this; |
||
| 194 | 42 | } |
|
| 195 | 42 | ||
| 196 | 42 | /** |
|
| 197 | 42 | * @inheritDoc |
|
| 198 | 42 | */ |
|
| 199 | 42 | public function disconnect() |
|
| 200 | { |
||
| 201 | $this->connection = null; |
||
| 202 | 1 | } |
|
| 203 | 1 | ||
| 204 | 1 | /** |
|
| 205 | * @inheritDoc |
||
| 206 | 1 | */ |
|
| 207 | 1 | public function hasTransactions() |
|
| 208 | 1 | { |
|
| 209 | 1 | return true; |
|
| 210 | 1 | } |
|
| 211 | 1 | ||
| 212 | 42 | /** |
|
| 213 | 42 | * @inheritDoc |
|
| 214 | 37 | */ |
|
| 215 | public function beginTransaction() |
||
| 219 | 42 | ||
| 220 | 1 | /** |
|
| 221 | 1 | * @inheritDoc |
|
| 222 | 1 | */ |
|
| 223 | 1 | public function commitTransaction() |
|
| 227 | 42 | ||
| 228 | /** |
||
| 229 | 42 | * @inheritDoc |
|
| 230 | 6 | */ |
|
| 231 | 42 | public function rollbackTransaction() |
|
| 235 | |||
| 236 | /** |
||
| 237 | 1 | * @inheritDoc |
|
| 238 | */ |
||
| 239 | 1 | public function quoteTableName($tableName) |
|
| 243 | |||
| 244 | /** |
||
| 245 | 1 | * @inheritDoc |
|
| 246 | */ |
||
| 247 | 1 | public function quoteColumnName($columnName) |
|
| 251 | |||
| 252 | /** |
||
| 253 | 1 | * @param string $tableName Table name |
|
| 254 | * @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 |
||
| 255 | 1 | * |
|
| 256 | 1 | * @return array |
|
| 257 | 1 | */ |
|
| 258 | 1 | protected function getSchemaName($tableName, $quoted = false) |
|
| 275 | 1 | ||
| 276 | 1 | /** |
|
| 277 | * Retrieves information about a given table from one of the SQLite pragmas |
||
| 278 | 1 | * |
|
| 279 | 1 | * @param string $tableName The table to query |
|
| 280 | 1 | * @param string $pragma The pragma to query |
|
| 281 | * |
||
| 282 | 1 | * @return array |
|
| 283 | 1 | */ |
|
| 284 | 1 | protected function getTableInfo($tableName, $pragma = 'table_info') |
|
| 290 | |||
| 291 | /** |
||
| 292 | * Searches through all available schemata to find a table and returns an array |
||
| 293 | * containing the bare schema name and whether the table exists at all. |
||
| 294 | * If no schema was specified and the table does not exist the "main" schema is returned |
||
| 295 | 8 | * |
|
| 296 | * @param string $tableName The name of the table to find |
||
| 297 | 8 | * |
|
| 298 | 8 | * @return array |
|
| 299 | 8 | */ |
|
| 300 | 7 | protected function resolveTable($tableName) |
|
| 345 | 2 | ||
| 346 | 2 | /** |
|
| 347 | * @inheritDoc |
||
| 348 | 2 | */ |
|
| 349 | 1 | public function hasTable($tableName) |
|
| 353 | |||
| 354 | 1 | /** |
|
| 355 | * @inheritDoc |
||
| 356 | 1 | */ |
|
| 357 | 1 | public function createTable(Table $table, array $columns = [], array $indexes = []) |
|
| 419 | |||
| 420 | 6 | /** |
|
| 421 | * {@inheritDoc} |
||
| 422 | 6 | * |
|
| 423 | 6 | * @throws \InvalidArgumentException |
|
| 424 | 6 | */ |
|
| 425 | 6 | protected function getChangePrimaryKeyInstructions(Table $table, $newColumns) |
|
| 454 | 2 | ||
| 455 | 2 | /** |
|
| 456 | 2 | * @inheritDoc |
|
| 457 | 2 | * |
|
| 458 | 2 | * SQLiteAdapter does not implement this functionality, and so will always throw an exception if used. |
|
| 459 | 2 | * |
|
| 460 | * @throws \BadMethodCallException |
||
| 461 | 2 | */ |
|
| 462 | protected function getChangeCommentInstructions(Table $table, $newComment) |
||
| 466 | |||
| 467 | /** |
||
| 468 | * @inheritDoc |
||
| 469 | 2 | */ |
|
| 470 | protected function getRenameTableInstructions($tableName, $newTableName) |
||
| 481 | 2 | ||
| 482 | /** |
||
| 483 | 2 | * @inheritDoc |
|
| 484 | 2 | */ |
|
| 485 | 2 | protected function getDropTableInstructions($tableName) |
|
| 492 | 2 | ||
| 493 | 2 | /** |
|
| 494 | * @inheritDoc |
||
| 495 | */ |
||
| 496 | public function truncateTable($tableName) |
||
| 497 | { |
||
| 498 | $info = $this->resolveTable($tableName); |
||
| 499 | // first try deleting the rows |
||
| 500 | $this->execute(sprintf( |
||
| 501 | 9 | 'DELETE FROM %s.%s', |
|
| 502 | $this->quoteColumnName($info['schema']), |
||
| 503 | 9 | $this->quoteColumnName($info['table']) |
|
| 504 | 9 | )); |
|
| 505 | |||
| 506 | 9 | // assuming no error occurred, reset the autoincrement (if any) |
|
| 507 | 9 | if ($this->hasTable($info['schema'] . '.sqlite_sequence')) { |
|
| 508 | 9 | $this->execute(sprintf( |
|
| 509 | 9 | 'DELETE FROM %s.%s where name = %s', |
|
| 510 | 9 | $this->quoteColumnName($info['schema']), |
|
| 511 | 9 | 'sqlite_sequence', |
|
| 512 | 9 | $this->quoteString($info['table']) |
|
| 513 | 9 | )); |
|
| 514 | 9 | } |
|
| 515 | 9 | } |
|
| 516 | |||
| 517 | /** |
||
| 518 | * Parses a default-value expression to yield either a Literal representing |
||
| 519 | * a string value, a string representing an expression, or some other scalar |
||
| 520 | * |
||
| 521 | 9 | * @param mixed $v The default-value expression to interpret |
|
| 522 | * @param string $t The Phinx type of the column |
||
| 523 | 9 | * |
|
| 524 | 4 | * @return mixed |
|
| 525 | 4 | */ |
|
| 526 | protected function parseDefaultValue($v, $t) |
||
| 589 | 1 | ||
| 590 | 1 | /** |
|
| 591 | 1 | * Returns the name of the specified table's identity column, or null if the table has no identity |
|
| 592 | 1 | * |
|
| 593 | 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 |
|
| 594 | 1 | * |
|
| 595 | 1 | * @param string $tableName The name of the table |
|
| 596 | 1 | * |
|
| 597 | 1 | * @return string|null |
|
| 598 | */ |
||
| 599 | protected function resolveIdentity($tableName) |
||
| 633 | 5 | ||
| 634 | 5 | /** |
|
| 635 | * @inheritDoc |
||
| 636 | 1 | */ |
|
| 637 | public function getColumns($tableName) |
||
| 662 | |||
| 663 | 5 | /** |
|
| 664 | 5 | * @inheritDoc |
|
| 665 | 5 | */ |
|
| 666 | 5 | public function hasColumn($tableName, $columnName) |
|
| 677 | |||
| 678 | /** |
||
| 679 | 4 | * @inheritDoc |
|
| 680 | */ |
||
| 681 | protected function getAddColumnInstructions(Table $table, Column $column) |
||
| 707 | 4 | ||
| 708 | 4 | /** |
|
| 709 | 4 | * Returns the original CREATE statement for the give table |
|
| 710 | 4 | * |
|
| 711 | 4 | * @param string $tableName The table name to get the create statement for |
|
| 712 | * |
||
| 713 | 4 | * @return string |
|
| 714 | 4 | */ |
|
| 715 | 4 | protected function getDeclaringSql($tableName) |
|
| 728 | |||
| 729 | 1 | /** |
|
| 730 | * Returns the original CREATE statement for the give index |
||
| 731 | 1 | * |
|
| 732 | 1 | * @param string $tableName The table name to get the create statement for |
|
| 733 | 1 | * @return string |
|
| 734 | 1 | */ |
|
| 735 | 1 | protected function getDeclaringIndexSql($tableName, $indexName) |
|
| 748 | 1 | ||
| 749 | /** |
||
| 750 | * Copies all the data from a tmp table to another table |
||
| 751 | * |
||
| 752 | * @param string $tableName The table name to copy the data to |
||
| 753 | * @param string $tmpTableName The tmp table name where the data is stored |
||
| 754 | 1 | * @param string[] $writeColumns The list of columns in the target table |
|
| 755 | * @param string[] $selectColumns The list of columns in the tmp table |
||
| 756 | 1 | * |
|
| 757 | 1 | * @return void |
|
| 758 | 1 | */ |
|
| 759 | 1 | protected function copyDataToNewTable($tableName, $tmpTableName, $writeColumns, $selectColumns) |
|
| 770 | 1 | ||
| 771 | /** |
||
| 772 | 1 | * Modifies the passed instructions to copy all data from the table into |
|
| 773 | * the provided tmp table and then drops the table and rename tmp table. |
||
| 774 | 1 | * |
|
| 775 | 1 | * @param \Phinx\Db\Util\AlterInstructions $instructions The instructions to modify |
|
| 776 | 1 | * @param string $tableName The table name to copy the data to |
|
| 777 | * |
||
| 778 | * @return \Phinx\Db\Util\AlterInstructions |
||
| 779 | */ |
||
| 780 | protected function copyAndDropTmpTable($instructions, $tableName) |
||
| 802 | |||
| 803 | /** |
||
| 804 | * Returns the columns and type to use when copying a table to another in the process |
||
| 805 | * of altering a table |
||
| 806 | * |
||
| 807 | * @param string $tableName The table to modify |
||
| 808 | * @param string|false $columnName The column name that is about to change |
||
| 809 | * @param string|false $newColumnName Optionally the new name for the column |
||
| 810 | 43 | * |
|
| 811 | * @throws \InvalidArgumentException |
||
| 812 | * |
||
| 813 | 43 | * @return array |
|
| 814 | 42 | */ |
|
| 815 | protected function calculateNewTableColumns($tableName, $columnName, $newColumnName) |
||
| 851 | 42 | ||
| 852 | /** |
||
| 853 | 5 | * Returns the initial instructions to alter a table using the |
|
| 854 | * create-copy-drop strategy |
||
| 855 | 5 | * |
|
| 856 | 4 | * @param string $tableName The table to modify |
|
| 857 | * |
||
| 858 | * @return \Phinx\Db\Util\AlterInstructions |
||
| 859 | */ |
||
| 860 | 1 | protected function beginAlterByCopyTable($tableName) |
|
| 885 | 2 | ||
| 886 | 2 | /** |
|
| 887 | 2 | * @inheritDoc |
|
| 888 | 2 | */ |
|
| 889 | 1 | protected function getRenameColumnInstructions($tableName, $columnName, $newColumnName) |
|
| 912 | |||
| 913 | /** |
||
| 914 | * @inheritDoc |
||
| 915 | */ |
||
| 916 | 2 | protected function getChangeColumnInstructions($tableName, $columnName, Column $newColumn) |
|
| 941 | |||
| 942 | /** |
||
| 943 | * @inheritDoc |
||
| 944 | */ |
||
| 945 | protected function getDropColumnInstructions($tableName, $columnName) |
||
| 973 | |||
| 974 | /** |
||
| 975 | 42 | * Get an array of indexes from a particular table. |
|
| 976 | * |
||
| 977 | 42 | * @param string $tableName Table name |
|
| 978 | 8 | * |
|
| 979 | 42 | * @return array |
|
| 980 | 42 | */ |
|
| 981 | 42 | protected function getIndexes($tableName) |
|
| 998 | |||
| 999 | 42 | /** |
|
| 1000 | 42 | * Finds the names of a table's indexes matching the supplied columns |
|
| 1001 | 42 | * |
|
| 1002 | 42 | * @param string $tableName The table to which the index belongs |
|
| 1003 | 42 | * @param string|string[] $columns The columns of the index |
|
| 1004 | 4 | * |
|
| 1005 | 4 | * @return array |
|
| 1006 | */ |
||
| 1007 | 42 | protected function resolveIndex($tableName, $columns) |
|
| 1022 | |||
| 1023 | /** |
||
| 1024 | * @inheritDoc |
||
| 1025 | */ |
||
| 1026 | public function hasIndex($tableName, $columns) |
||
| 1030 | 42 | ||
| 1031 | 2 | /** |
|
| 1032 | * @inheritDoc |
||
| 1033 | 42 | */ |
|
| 1034 | public function hasIndexByName($tableName, $indexName) |
||
| 1047 | 6 | ||
| 1048 | /** |
||
| 1049 | 8 | * @inheritDoc |
|
| 1050 | 3 | */ |
|
| 1051 | 3 | protected function getAddIndexInstructions(Table $table, Index $index) |
|
| 1067 | 47 | ||
| 1068 | /** |
||
| 1069 | * @inheritDoc |
||
| 1070 | */ |
||
| 1071 | protected function getDropIndexByColumnsInstructions($tableName, $columns) |
||
| 1088 | 5 | ||
| 1089 | 5 | /** |
|
| 1090 | 5 | * @inheritDoc |
|
| 1091 | 5 | */ |
|
| 1092 | 5 | protected function getDropIndexByNameInstructions($tableName, $indexName) |
|
| 1117 | |||
| 1118 | /** |
||
| 1119 | * {@inheritDoc} |
||
| 1120 | * |
||
| 1121 | * @throws \InvalidArgumentException |
||
| 1122 | */ |
||
| 1123 | public function hasPrimaryKey($tableName, $columns, $constraint = null) |
||
| 1138 | |||
| 1139 | /** |
||
| 1140 | * Get the primary key from a particular table. |
||
| 1141 | * |
||
| 1142 | * @param string $tableName Table name |
||
| 1143 | * |
||
| 1144 | * @return string[] |
||
| 1145 | */ |
||
| 1146 | protected function getPrimaryKey($tableName) |
||
| 1160 | |||
| 1161 | /** |
||
| 1162 | * {@inheritDoc} |
||
| 1163 | * |
||
| 1164 | * @throws \InvalidArgumentException |
||
| 1165 | */ |
||
| 1166 | public function hasForeignKey($tableName, $columns, $constraint = null) |
||
| 1186 | |||
| 1187 | /** |
||
| 1188 | * Get an array of foreign keys from a particular table. |
||
| 1189 | * |
||
| 1190 | * @param string $tableName Table name |
||
| 1191 | * |
||
| 1192 | * @return array |
||
| 1193 | */ |
||
| 1194 | protected function getForeignKeys($tableName) |
||
| 1209 | |||
| 1210 | /** |
||
| 1211 | * @param \Phinx\Db\Table\Table $table The Table |
||
| 1212 | * @param string $column Column Name |
||
| 1213 | * |
||
| 1214 | * @return \Phinx\Db\Util\AlterInstructions |
||
| 1215 | */ |
||
| 1216 | protected function getAddPrimaryKeyInstructions(Table $table, $column) |
||
| 1253 | |||
| 1254 | /** |
||
| 1255 | * @param \Phinx\Db\Table\Table $table Table |
||
| 1256 | * @param string $column Column Name |
||
| 1257 | * |
||
| 1258 | * @return \Phinx\Db\Util\AlterInstructions |
||
| 1259 | */ |
||
| 1260 | protected function getDropPrimaryKeyInstructions($table, $column) |
||
| 1283 | |||
| 1284 | /** |
||
| 1285 | * @inheritDoc |
||
| 1286 | */ |
||
| 1287 | protected function getAddForeignKeyInstructions(Table $table, ForeignKey $foreignKey) |
||
| 1329 | |||
| 1330 | /** |
||
| 1331 | * @inheritDoc |
||
| 1332 | * |
||
| 1333 | * SQLiteAdapter does not implement this functionality, and so will always throw an exception if used. |
||
| 1334 | * |
||
| 1335 | * @throws \BadMethodCallException |
||
| 1336 | */ |
||
| 1337 | protected function getDropForeignKeyInstructions($tableName, $constraint) |
||
| 1341 | |||
| 1342 | /** |
||
| 1343 | * {@inheritDoc} |
||
| 1344 | * |
||
| 1345 | * @throws \InvalidArgumentException |
||
| 1346 | */ |
||
| 1347 | protected function getDropForeignKeyByColumnsInstructions($tableName, $columns) |
||
| 1387 | |||
| 1388 | /** |
||
| 1389 | * {@inheritDoc} |
||
| 1390 | * |
||
| 1391 | * @throws \Phinx\Db\Adapter\UnsupportedColumnTypeException |
||
| 1392 | */ |
||
| 1393 | public function getSqlType($type, $limit = null) |
||
| 1408 | |||
| 1409 | /** |
||
| 1410 | * Returns Phinx type by SQL type |
||
| 1411 | * |
||
| 1412 | * @param string|null $sqlTypeDef SQL Type definition |
||
| 1413 | * |
||
| 1414 | * @return array |
||
| 1415 | */ |
||
| 1416 | public function getPhinxType($sqlTypeDef) |
||
| 1458 | |||
| 1459 | /** |
||
| 1460 | * @inheritDoc |
||
| 1461 | */ |
||
| 1462 | public function createDatabase($name, $options = []) |
||
| 1466 | |||
| 1467 | /** |
||
| 1468 | * @inheritDoc |
||
| 1469 | */ |
||
| 1470 | public function hasDatabase($name) |
||
| 1474 | |||
| 1475 | /** |
||
| 1476 | * @inheritDoc |
||
| 1477 | */ |
||
| 1478 | public function dropDatabase($name) |
||
| 1488 | |||
| 1489 | /** |
||
| 1490 | * Gets the SQLite Column Definition for a Column object. |
||
| 1491 | * |
||
| 1492 | * @param \Phinx\Db\Table\Column $column Column |
||
| 1493 | * |
||
| 1494 | * @return string |
||
| 1495 | */ |
||
| 1496 | protected function getColumnSqlDefinition(Column $column) |
||
| 1524 | |||
| 1525 | /** |
||
| 1526 | * Gets the comment Definition for a Column object. |
||
| 1527 | * |
||
| 1528 | * @param \Phinx\Db\Table\Column $column Column |
||
| 1529 | * |
||
| 1530 | * @return string |
||
| 1531 | */ |
||
| 1532 | protected function getCommentDefinition(Column $column) |
||
| 1540 | |||
| 1541 | /** |
||
| 1542 | * Gets the SQLite Index Definition for an Index object. |
||
| 1543 | * |
||
| 1544 | * @param \Phinx\Db\Table\Table $table Table |
||
| 1545 | * @param \Phinx\Db\Table\Index $index Index |
||
| 1546 | * |
||
| 1547 | * @return string |
||
| 1548 | */ |
||
| 1549 | protected function getIndexSqlDefinition(Table $table, Index $index) |
||
| 1569 | |||
| 1570 | /** |
||
| 1571 | * @inheritDoc |
||
| 1572 | */ |
||
| 1573 | public function getColumnTypes() |
||
| 1574 | { |
||
| 1575 | return array_keys(static::$supportedColumnTypes); |
||
| 1576 | } |
||
| 1577 | |||
| 1578 | /** |
||
| 1579 | * Gets the SQLite Foreign Key Definition for an ForeignKey object. |
||
| 1580 | * |
||
| 1581 | * @param \Phinx\Db\Table\ForeignKey $foreignKey Foreign key |
||
| 1582 | * |
||
| 1583 | * @return string |
||
| 1584 | */ |
||
| 1585 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey) |
||
| 1610 | |||
| 1611 | /** |
||
| 1612 | * @inheritDoc |
||
| 1613 | */ |
||
| 1614 | public function getDecoratedConnection() |
||
| 1636 | } |
||
| 1637 |
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.