Complex classes like DBSchemaManager 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 DBSchemaManager, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 15 | abstract class DBSchemaManager { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * |
||
| 19 | * @config |
||
| 20 | * Check tables when running /dev/build, and repair them if necessary. |
||
| 21 | * In case of large databases or more fine-grained control on how to handle |
||
| 22 | * data corruption in tables, you can disable this behaviour and handle it |
||
| 23 | * outside of this class, e.g. through a nightly system task with extended logging capabilities. |
||
| 24 | * |
||
| 25 | * @var bool |
||
| 26 | */ |
||
| 27 | private static $check_and_repair_on_build = true; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Check if tables should be renamed in a case-sensitive fashion. |
||
| 31 | * Note: This should still work even on case-insensitive databases. |
||
| 32 | * |
||
| 33 | * @var bool |
||
| 34 | */ |
||
| 35 | private static $fix_table_case_on_build = true; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Instance of the database controller this schema belongs to |
||
| 39 | * |
||
| 40 | * @var Database |
||
| 41 | */ |
||
| 42 | protected $database = null; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * If this is false, then information about database operations |
||
| 46 | * will be displayed, eg creation of tables. |
||
| 47 | * |
||
| 48 | * @var boolean |
||
| 49 | */ |
||
| 50 | protected $supressOutput = false; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Injector injection point for database controller |
||
| 54 | * |
||
| 55 | * @param Database $database |
||
| 56 | */ |
||
| 57 | public function setDatabase(Database $database) { |
||
| 60 | |||
| 61 | /** |
||
| 62 | * The table list, generated by the tableList() function. |
||
| 63 | * Used by the requireTable() function. |
||
| 64 | * |
||
| 65 | * @var array |
||
| 66 | */ |
||
| 67 | protected $tableList; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Keeps track whether we are currently updating the schema. |
||
| 71 | * |
||
| 72 | * @var boolean |
||
| 73 | */ |
||
| 74 | protected $schemaIsUpdating = false; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Large array structure that represents a schema update transaction |
||
| 78 | * |
||
| 79 | * @var array |
||
| 80 | */ |
||
| 81 | protected $schemaUpdateTransaction; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Enable supression of database messages. |
||
| 85 | */ |
||
| 86 | public function quiet() { |
||
| 89 | |||
| 90 | /** |
||
| 91 | * Execute the given SQL query. |
||
| 92 | * This abstract function must be defined by subclasses as part of the actual implementation. |
||
| 93 | * It should return a subclass of SS_Query as the result. |
||
| 94 | * |
||
| 95 | * @param string $sql The SQL query to execute |
||
| 96 | * @param int $errorLevel The level of error reporting to enable for the query |
||
| 97 | * @return Query |
||
| 98 | */ |
||
| 99 | public function query($sql, $errorLevel = E_USER_ERROR) { |
||
| 102 | |||
| 103 | |||
| 104 | /** |
||
| 105 | * Execute the given SQL parameterised query with the specified arguments |
||
| 106 | * |
||
| 107 | * @param string $sql The SQL query to execute. The ? character will denote parameters. |
||
| 108 | * @param array $parameters An ordered list of arguments. |
||
| 109 | * @param int $errorLevel The level of error reporting to enable for the query |
||
| 110 | * @return Query |
||
| 111 | */ |
||
| 112 | public function preparedQuery($sql, $parameters, $errorLevel = E_USER_ERROR) { |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Initiates a schema update within a single callback |
||
| 118 | * |
||
| 119 | * @param callable $callback |
||
| 120 | */ |
||
| 121 | public function schemaUpdate($callback) { |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Cancels the schema updates requested during (but not after) schemaUpdate() call. |
||
| 169 | */ |
||
| 170 | public function cancelSchemaUpdate() { |
||
| 174 | |||
| 175 | /** |
||
| 176 | * Returns true if we are during a schema update. |
||
| 177 | * |
||
| 178 | * @return boolean |
||
| 179 | */ |
||
| 180 | function isSchemaUpdating() { |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Returns true if schema modifications were requested during (but not after) schemaUpdate() call. |
||
| 186 | * |
||
| 187 | * @return boolean |
||
| 188 | */ |
||
| 189 | public function doesSchemaNeedUpdating() { |
||
| 192 | |||
| 193 | // Transactional schema altering functions - they don't do anything except for update schemaUpdateTransaction |
||
| 194 | |||
| 195 | /** |
||
| 196 | * Instruct the schema manager to record a table creation to later execute |
||
| 197 | * |
||
| 198 | * @param string $table Name of the table |
||
| 199 | * @param array $options Create table options (ENGINE, etc.) |
||
| 200 | * @param array $advanced_options Advanced table creation options |
||
| 201 | */ |
||
| 202 | public function transCreateTable($table, $options = null, $advanced_options = null) { |
||
| 211 | |||
| 212 | /** |
||
| 213 | * Instruct the schema manager to record a table alteration to later execute |
||
| 214 | * |
||
| 215 | * @param string $table Name of the table |
||
| 216 | * @param array $options Create table options (ENGINE, etc.) |
||
| 217 | * @param array $advanced_options Advanced table creation options |
||
| 218 | */ |
||
| 219 | public function transAlterTable($table, $options, $advanced_options) { |
||
| 224 | |||
| 225 | /** |
||
| 226 | * Instruct the schema manager to record a field to be later created |
||
| 227 | * |
||
| 228 | * @param string $table Name of the table to hold this field |
||
| 229 | * @param string $field Name of the field to create |
||
| 230 | * @param string $schema Field specification as a string |
||
| 231 | */ |
||
| 232 | public function transCreateField($table, $field, $schema) { |
||
| 236 | |||
| 237 | /** |
||
| 238 | * Instruct the schema manager to record an index to be later created |
||
| 239 | * |
||
| 240 | * @param string $table Name of the table to hold this index |
||
| 241 | * @param string $index Name of the index to create |
||
| 242 | * @param array $schema Already parsed index specification |
||
| 243 | */ |
||
| 244 | public function transCreateIndex($table, $index, $schema) { |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Instruct the schema manager to record a field to be later updated |
||
| 251 | * |
||
| 252 | * @param string $table Name of the table to hold this field |
||
| 253 | * @param string $field Name of the field to update |
||
| 254 | * @param string $schema Field specification as a string |
||
| 255 | */ |
||
| 256 | public function transAlterField($table, $field, $schema) { |
||
| 260 | |||
| 261 | /** |
||
| 262 | * Instruct the schema manager to record an index to be later updated |
||
| 263 | * |
||
| 264 | * @param string $table Name of the table to hold this index |
||
| 265 | * @param string $index Name of the index to update |
||
| 266 | * @param array $schema Already parsed index specification |
||
| 267 | */ |
||
| 268 | public function transAlterIndex($table, $index, $schema) { |
||
| 272 | |||
| 273 | /** |
||
| 274 | * Handler for the other transXXX methods - mark the given table as being altered |
||
| 275 | * if it doesn't already exist |
||
| 276 | * |
||
| 277 | * @param string $table Name of the table to initialise |
||
| 278 | */ |
||
| 279 | protected function transInitTable($table) { |
||
| 291 | |||
| 292 | /** |
||
| 293 | * Generate the following table in the database, modifying whatever already exists |
||
| 294 | * as necessary. |
||
| 295 | * |
||
| 296 | * @todo Change detection for CREATE TABLE $options other than "Engine" |
||
| 297 | * |
||
| 298 | * @param string $table The name of the table |
||
| 299 | * @param array $fieldSchema A list of the fields to create, in the same form as DataObject::$db |
||
| 300 | * @param array $indexSchema A list of indexes to create. See {@link requireIndex()} |
||
| 301 | * The values of the array can be one of: |
||
| 302 | * - true: Create a single column index on the field named the same as the index. |
||
| 303 | * - array('fields' => array('A','B','C'), 'type' => 'index/unique/fulltext'): This gives you full |
||
| 304 | * control over the index. |
||
| 305 | * @param boolean $hasAutoIncPK A flag indicating that the primary key on this table is an autoincrement type |
||
| 306 | * @param array $options Create table options (ENGINE, etc.) |
||
| 307 | * @param array|bool $extensions List of extensions |
||
| 308 | */ |
||
| 309 | public function requireTable($table, $fieldSchema = null, $indexSchema = null, $hasAutoIncPK = true, |
||
| 381 | |||
| 382 | /** |
||
| 383 | * If the given table exists, move it out of the way by renaming it to _obsolete_(tablename). |
||
| 384 | * @param string $table The table name. |
||
| 385 | */ |
||
| 386 | public function dontRequireTable($table) { |
||
| 398 | |||
| 399 | /** |
||
| 400 | * Generate the given index in the database, modifying whatever already exists as necessary. |
||
| 401 | * |
||
| 402 | * The keys of the array are the names of the index. |
||
| 403 | * The values of the array can be one of: |
||
| 404 | * - true: Create a single column index on the field named the same as the index. |
||
| 405 | * - array('type' => 'index|unique|fulltext', 'value' => 'FieldA, FieldB'): This gives you full |
||
| 406 | * control over the index. |
||
| 407 | * |
||
| 408 | * @param string $table The table name. |
||
| 409 | * @param string $index The index name. |
||
| 410 | * @param string|array|boolean $spec The specification of the index in any |
||
| 411 | * loose format. See requireTable() for more information. |
||
| 412 | */ |
||
| 413 | public function requireIndex($table, $index, $spec) { |
||
| 449 | |||
| 450 | /** |
||
| 451 | * Splits a spec string safely, considering quoted columns, whitespace, |
||
| 452 | * and cleaning brackets |
||
| 453 | * |
||
| 454 | * @param string $spec The input index specification string |
||
| 455 | * @return array List of columns in the spec |
||
| 456 | */ |
||
| 457 | protected function explodeColumnString($spec) { |
||
| 466 | |||
| 467 | /** |
||
| 468 | * Builds a properly quoted column list from an array |
||
| 469 | * |
||
| 470 | * @param array $columns List of columns to implode |
||
| 471 | * @return string A properly quoted list of column names |
||
| 472 | */ |
||
| 473 | protected function implodeColumnList($columns) { |
||
| 477 | |||
| 478 | /** |
||
| 479 | * Given an index specification in the form of a string ensure that each |
||
| 480 | * column name is property quoted, stripping brackets and modifiers. |
||
| 481 | * This index may also be in the form of a "CREATE INDEX..." sql fragment |
||
| 482 | * |
||
| 483 | * @param string $spec The input specification or query. E.g. 'unique (Column1, Column2)' |
||
| 484 | * @return string The properly quoted column list. E.g. '"Column1", "Column2"' |
||
| 485 | */ |
||
| 486 | protected function quoteColumnSpecString($spec) { |
||
| 490 | |||
| 491 | /** |
||
| 492 | * Given an index spec determines the index type |
||
| 493 | * |
||
| 494 | * @param array|string $spec |
||
| 495 | * @return string |
||
| 496 | */ |
||
| 497 | protected function determineIndexType($spec) { |
||
| 507 | |||
| 508 | /** |
||
| 509 | * Converts an array or string index spec into a universally useful array |
||
| 510 | * |
||
| 511 | * @see convertIndexSpec() for approximate inverse |
||
| 512 | * @param string $name Index name |
||
| 513 | * @param string|array $spec |
||
| 514 | * @return array The resulting spec array with the required fields name, type, and value |
||
| 515 | */ |
||
| 516 | protected function parseIndexSpec($name, $spec) { |
||
| 540 | |||
| 541 | /** |
||
| 542 | * This takes the index spec which has been provided by a class (ie static $indexes = blah blah) |
||
| 543 | * and turns it into a proper string. |
||
| 544 | * Some indexes may be arrays, such as fulltext and unique indexes, and this allows database-specific |
||
| 545 | * arrays to be created. See {@link requireTable()} for details on the index format. |
||
| 546 | * |
||
| 547 | * @see http://dev.mysql.com/doc/refman/5.0/en/create-index.html |
||
| 548 | * @see parseIndexSpec() for approximate inverse |
||
| 549 | * |
||
| 550 | * @param string|array $indexSpec |
||
| 551 | * @return string |
||
| 552 | */ |
||
| 553 | protected function convertIndexSpec($indexSpec) { |
||
| 562 | |||
| 563 | /** |
||
| 564 | * Returns true if the given table is exists in the current database |
||
| 565 | * |
||
| 566 | * @param string $tableName Name of table to check |
||
| 567 | * @return boolean Flag indicating existence of table |
||
| 568 | */ |
||
| 569 | abstract public function hasTable($tableName); |
||
| 570 | |||
| 571 | /** |
||
| 572 | * Return true if the table exists and already has a the field specified |
||
| 573 | * |
||
| 574 | * @param string $tableName - The table to check |
||
| 575 | * @param string $fieldName - The field to check |
||
| 576 | * @return bool - True if the table exists and the field exists on the table |
||
| 577 | */ |
||
| 578 | public function hasField($tableName, $fieldName) { |
||
| 583 | |||
| 584 | /** |
||
| 585 | * Generate the given field on the table, modifying whatever already exists as necessary. |
||
| 586 | * |
||
| 587 | * @param string $table The table name. |
||
| 588 | * @param string $field The field name. |
||
| 589 | * @param array|string $spec The field specification. If passed in array syntax, the specific database |
||
| 590 | * driver takes care of the ALTER TABLE syntax. If passed as a string, its assumed to |
||
| 591 | * be prepared as a direct SQL framgment ready for insertion into ALTER TABLE. In this case you'll |
||
| 592 | * need to take care of database abstraction in your DBField subclass. |
||
| 593 | */ |
||
| 594 | public function requireField($table, $field, $spec) { |
||
| 690 | |||
| 691 | /** |
||
| 692 | * If the given field exists, move it out of the way by renaming it to _obsolete_(fieldname). |
||
| 693 | * |
||
| 694 | * @param string $table |
||
| 695 | * @param string $fieldName |
||
| 696 | */ |
||
| 697 | public function dontRequireField($table, $fieldName) { |
||
| 713 | |||
| 714 | /** |
||
| 715 | * Show a message about database alteration |
||
| 716 | * |
||
| 717 | * @param string $message to display |
||
| 718 | * @param string $type one of [created|changed|repaired|obsolete|deleted|error] |
||
| 719 | */ |
||
| 720 | public function alterationMessage($message, $type = "") { |
||
| 774 | |||
| 775 | /** |
||
| 776 | * This returns the data type for the id column which is the primary key for each table |
||
| 777 | * |
||
| 778 | * @param boolean $asDbValue |
||
| 779 | * @param boolean $hasAutoIncPK |
||
| 780 | * @return string |
||
| 781 | */ |
||
| 782 | abstract public function IdColumn($asDbValue = false, $hasAutoIncPK = true); |
||
| 783 | |||
| 784 | /** |
||
| 785 | * Checks a table's integrity and repairs it if necessary. |
||
| 786 | * |
||
| 787 | * @param string $tableName The name of the table. |
||
| 788 | * @return boolean Return true if the table has integrity after the method is complete. |
||
| 789 | */ |
||
| 790 | abstract public function checkAndRepairTable($tableName); |
||
| 791 | |||
| 792 | |||
| 793 | /** |
||
| 794 | * Ensure the given table has the correct case |
||
| 795 | * |
||
| 796 | * @param string $tableName Name of table in desired case |
||
| 797 | */ |
||
| 798 | public function fixTableCase($tableName) |
||
| 822 | |||
| 823 | /** |
||
| 824 | * Returns the values of the given enum field |
||
| 825 | * |
||
| 826 | * @param string $tableName Name of table to check |
||
| 827 | * @param string $fieldName name of enum field to check |
||
| 828 | * @return array List of enum values |
||
| 829 | */ |
||
| 830 | abstract public function enumValuesForField($tableName, $fieldName); |
||
| 831 | |||
| 832 | |||
| 833 | /* |
||
| 834 | * This is a lookup table for data types. |
||
| 835 | * For instance, Postgres uses 'INT', while MySQL uses 'UNSIGNED' |
||
| 836 | * So this is a DB-specific list of equivilents. |
||
| 837 | * |
||
| 838 | * @param string $type |
||
| 839 | * @return string |
||
| 840 | */ |
||
| 841 | abstract public function dbDataType($type); |
||
| 842 | |||
| 843 | /** |
||
| 844 | * Retrieves the list of all databases the user has access to |
||
| 845 | * |
||
| 846 | * @return array List of database names |
||
| 847 | */ |
||
| 848 | abstract public function databaseList(); |
||
| 849 | |||
| 850 | /** |
||
| 851 | * Determine if the database with the specified name exists |
||
| 852 | * |
||
| 853 | * @param string $name Name of the database to check for |
||
| 854 | * @return boolean Flag indicating whether this database exists |
||
| 855 | */ |
||
| 856 | abstract public function databaseExists($name); |
||
| 857 | |||
| 858 | /** |
||
| 859 | * Create a database with the specified name |
||
| 860 | * |
||
| 861 | * @param string $name Name of the database to create |
||
| 862 | * @return boolean True if successful |
||
| 863 | */ |
||
| 864 | abstract public function createDatabase($name); |
||
| 865 | |||
| 866 | /** |
||
| 867 | * Drops a database with the specified name |
||
| 868 | * |
||
| 869 | * @param string $name Name of the database to drop |
||
| 870 | */ |
||
| 871 | abstract public function dropDatabase($name); |
||
| 872 | |||
| 873 | /** |
||
| 874 | * Alter an index on a table. |
||
| 875 | * |
||
| 876 | * @param string $tableName The name of the table. |
||
| 877 | * @param string $indexName The name of the index. |
||
| 878 | * @param string $indexSpec The specification of the index, see {@link SS_Database::requireIndex()} |
||
| 879 | * for more details. |
||
| 880 | * @todo Find out where this is called from - Is it even used? Aren't indexes always dropped and re-added? |
||
| 881 | */ |
||
| 882 | abstract public function alterIndex($tableName, $indexName, $indexSpec); |
||
| 883 | |||
| 884 | /** |
||
| 885 | * Determines the key that should be used to identify this index |
||
| 886 | * when retrieved from DBSchemaManager->indexList. |
||
| 887 | * In some connectors this is the database-visible name, in others the |
||
| 888 | * usercode-visible name. |
||
| 889 | * |
||
| 890 | * @param string $table |
||
| 891 | * @param string $index |
||
| 892 | * @param array $spec |
||
| 893 | * @return string Key for this index |
||
| 894 | */ |
||
| 895 | abstract protected function indexKey($table, $index, $spec); |
||
| 896 | |||
| 897 | /** |
||
| 898 | * Return the list of indexes in a table. |
||
| 899 | * |
||
| 900 | * @param string $table The table name. |
||
| 901 | * @return array[array] List of current indexes in the table, each in standard |
||
| 902 | * array form. The key for this array should be predictable using the indexKey |
||
| 903 | * method |
||
| 904 | */ |
||
| 905 | abstract public function indexList($table); |
||
| 906 | |||
| 907 | /** |
||
| 908 | * Returns a list of all tables in the database. |
||
| 909 | * Keys are table names in lower case, values are table names in case that |
||
| 910 | * database expects. |
||
| 911 | * |
||
| 912 | * @return array |
||
| 913 | */ |
||
| 914 | abstract public function tableList(); |
||
| 915 | |||
| 916 | /** |
||
| 917 | * Create a new table. |
||
| 918 | * |
||
| 919 | * @param string $table The name of the table |
||
| 920 | * @param array $fields A map of field names to field types |
||
| 921 | * @param array $indexes A map of indexes |
||
| 922 | * @param array $options An map of additional options. The available keys are as follows: |
||
| 923 | * - 'MSSQLDatabase'/'MySQLDatabase'/'PostgreSQLDatabase' - database-specific options such as "engine" for MySQL. |
||
| 924 | * - 'temporary' - If true, then a temporary table will be created |
||
| 925 | * @param array $advancedOptions Advanced creation options |
||
| 926 | * @return string The table name generated. This may be different from the table name, for example with temporary |
||
| 927 | * tables. |
||
| 928 | */ |
||
| 929 | abstract public function createTable($table, $fields = null, $indexes = null, $options = null, |
||
| 931 | |||
| 932 | /** |
||
| 933 | * Alter a table's schema. |
||
| 934 | * |
||
| 935 | * @param string $table The name of the table to alter |
||
| 936 | * @param array $newFields New fields, a map of field name => field schema |
||
| 937 | * @param array $newIndexes New indexes, a map of index name => index type |
||
| 938 | * @param array $alteredFields Updated fields, a map of field name => field schema |
||
| 939 | * @param array $alteredIndexes Updated indexes, a map of index name => index type |
||
| 940 | * @param array $alteredOptions |
||
| 941 | * @param array $advancedOptions |
||
| 942 | */ |
||
| 943 | abstract public function alterTable($table, $newFields = null, $newIndexes = null, $alteredFields = null, |
||
| 945 | |||
| 946 | /** |
||
| 947 | * Rename a table. |
||
| 948 | * |
||
| 949 | * @param string $oldTableName The old table name. |
||
| 950 | * @param string $newTableName The new table name. |
||
| 951 | */ |
||
| 952 | abstract public function renameTable($oldTableName, $newTableName); |
||
| 953 | |||
| 954 | /** |
||
| 955 | * Create a new field on a table. |
||
| 956 | * |
||
| 957 | * @param string $table Name of the table. |
||
| 958 | * @param string $field Name of the field to add. |
||
| 959 | * @param string $spec The field specification, eg 'INTEGER NOT NULL' |
||
| 960 | */ |
||
| 961 | abstract public function createField($table, $field, $spec); |
||
| 962 | |||
| 963 | /** |
||
| 964 | * Change the database column name of the given field. |
||
| 965 | * |
||
| 966 | * @param string $tableName The name of the tbale the field is in. |
||
| 967 | * @param string $oldName The name of the field to change. |
||
| 968 | * @param string $newName The new name of the field |
||
| 969 | */ |
||
| 970 | abstract public function renameField($tableName, $oldName, $newName); |
||
| 971 | |||
| 972 | /** |
||
| 973 | * Get a list of all the fields for the given table. |
||
| 974 | * Returns a map of field name => field spec. |
||
| 975 | * |
||
| 976 | * @param string $table The table name. |
||
| 977 | * @return array |
||
| 978 | */ |
||
| 979 | abstract public function fieldList($table); |
||
| 980 | |||
| 981 | /** |
||
| 982 | * |
||
| 983 | * This allows the cached values for a table's field list to be erased. |
||
| 984 | * If $tablename is empty, then the whole cache is erased. |
||
| 985 | * |
||
| 986 | * @param string $tableName |
||
| 987 | * @return boolean |
||
| 988 | */ |
||
| 989 | public function clearCachedFieldlist($tableName = null) { |
||
| 992 | |||
| 993 | |||
| 994 | /** |
||
| 995 | * Returns data type for 'boolean' column |
||
| 996 | * |
||
| 997 | * @param array $values Contains a tokenised list of info about this data type |
||
| 998 | * @return string |
||
| 999 | */ |
||
| 1000 | abstract public function boolean($values); |
||
| 1001 | |||
| 1002 | /** |
||
| 1003 | * Returns data type for 'date' column |
||
| 1004 | * |
||
| 1005 | * @param array $values Contains a tokenised list of info about this data type |
||
| 1006 | * @return string |
||
| 1007 | */ |
||
| 1008 | abstract public function date($values); |
||
| 1009 | |||
| 1010 | /** |
||
| 1011 | * Returns data type for 'decimal' column |
||
| 1012 | * |
||
| 1013 | * @param array $values Contains a tokenised list of info about this data type |
||
| 1014 | * @return string |
||
| 1015 | */ |
||
| 1016 | abstract public function decimal($values); |
||
| 1017 | |||
| 1018 | /** |
||
| 1019 | * Returns data type for 'set' column |
||
| 1020 | * |
||
| 1021 | * @param array $values Contains a tokenised list of info about this data type |
||
| 1022 | * @return string |
||
| 1023 | */ |
||
| 1024 | abstract public function enum($values); |
||
| 1025 | |||
| 1026 | /** |
||
| 1027 | * Returns data type for 'set' column |
||
| 1028 | * |
||
| 1029 | * @param array $values Contains a tokenised list of info about this data type |
||
| 1030 | * @return string |
||
| 1031 | */ |
||
| 1032 | abstract public function set($values); |
||
| 1033 | |||
| 1034 | /** |
||
| 1035 | * Returns data type for 'float' column |
||
| 1036 | * |
||
| 1037 | * @param array $values Contains a tokenised list of info about this data type |
||
| 1038 | * @return string |
||
| 1039 | */ |
||
| 1040 | abstract public function float($values); |
||
| 1041 | |||
| 1042 | /** |
||
| 1043 | * Returns data type for 'int' column |
||
| 1044 | * |
||
| 1045 | * @param array $values Contains a tokenised list of info about this data type |
||
| 1046 | * @return string |
||
| 1047 | */ |
||
| 1048 | abstract public function int($values); |
||
| 1049 | |||
| 1050 | /** |
||
| 1051 | * Returns data type for 'datetime' column |
||
| 1052 | * |
||
| 1053 | * @param array $values Contains a tokenised list of info about this data type |
||
| 1054 | * @return string |
||
| 1055 | */ |
||
| 1056 | abstract public function datetime($values); |
||
| 1057 | |||
| 1058 | /** |
||
| 1059 | * Returns data type for 'text' column |
||
| 1060 | * |
||
| 1061 | * @param array $values Contains a tokenised list of info about this data type |
||
| 1062 | * @return string |
||
| 1063 | */ |
||
| 1064 | abstract public function text($values); |
||
| 1065 | |||
| 1066 | /** |
||
| 1067 | * Returns data type for 'time' column |
||
| 1068 | * |
||
| 1069 | * @param array $values Contains a tokenised list of info about this data type |
||
| 1070 | * @return string |
||
| 1071 | */ |
||
| 1072 | abstract public function time($values); |
||
| 1073 | |||
| 1074 | /** |
||
| 1075 | * Returns data type for 'varchar' column |
||
| 1076 | * |
||
| 1077 | * @param array $values Contains a tokenised list of info about this data type |
||
| 1078 | * @return string |
||
| 1079 | */ |
||
| 1080 | abstract public function varchar($values); |
||
| 1081 | |||
| 1082 | /* |
||
| 1083 | * Returns data type for 'year' column |
||
| 1084 | * |
||
| 1085 | * @param array $values Contains a tokenised list of info about this data type |
||
| 1086 | * @return string |
||
| 1087 | */ |
||
| 1088 | abstract public function year($values); |
||
| 1089 | |||
| 1090 | } |
||
| 1091 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..