Complex classes like SQLServerPlatform 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 SQLServerPlatform, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
42 | class SQLServerPlatform extends AbstractPlatform |
||
43 | { |
||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 7727 | public function getCurrentDateSQL() |
|
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | 7722 | public function getCurrentTimeSQL() |
|
59 | |||
60 | /** |
||
61 | * Returns an expression that converts an expression of one data type to another. |
||
62 | * |
||
63 | * @param string $dataType The target native data type. Alias data types cannot be used. |
||
64 | * @param string $expression The SQL expression to convert. |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | 7727 | private function getConvertExpression($dataType, $expression) |
|
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 963 | protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) |
|
86 | |||
87 | /** |
||
88 | * {@inheritDoc} |
||
89 | */ |
||
90 | 942 | public function getDateDiffExpression($date1, $date2) |
|
94 | |||
95 | /** |
||
96 | * {@inheritDoc} |
||
97 | * |
||
98 | * Microsoft SQL Server prefers "autoincrement" identity columns |
||
99 | * since sequences can only be emulated with a table. |
||
100 | */ |
||
101 | 7345 | public function prefersIdentityColumns() |
|
105 | |||
106 | /** |
||
107 | * {@inheritDoc} |
||
108 | * |
||
109 | * Microsoft SQL Server supports this through AUTO_INCREMENT columns. |
||
110 | */ |
||
111 | 832 | public function supportsIdentityColumns() |
|
115 | |||
116 | /** |
||
117 | * {@inheritDoc} |
||
118 | */ |
||
119 | 1005 | public function supportsReleaseSavepoints() |
|
123 | |||
124 | /** |
||
125 | * {@inheritdoc} |
||
126 | */ |
||
127 | 862 | public function supportsSchemas() |
|
131 | |||
132 | /** |
||
133 | * {@inheritdoc} |
||
134 | */ |
||
135 | 805 | public function getDefaultSchemaName() |
|
139 | |||
140 | /** |
||
141 | * {@inheritDoc} |
||
142 | */ |
||
143 | 6344 | public function supportsColumnCollation() |
|
147 | |||
148 | /** |
||
149 | * {@inheritDoc} |
||
150 | */ |
||
151 | 7998 | public function hasNativeGuidType() |
|
155 | |||
156 | /** |
||
157 | * {@inheritDoc} |
||
158 | */ |
||
159 | 7763 | public function getCreateDatabaseSQL($name) |
|
163 | |||
164 | /** |
||
165 | * {@inheritDoc} |
||
166 | */ |
||
167 | 7763 | public function getDropDatabaseSQL($name) |
|
171 | |||
172 | /** |
||
173 | * {@inheritDoc} |
||
174 | */ |
||
175 | 1022 | public function supportsCreateDropDatabase() |
|
179 | |||
180 | /** |
||
181 | * {@inheritDoc} |
||
182 | */ |
||
183 | 6994 | public function getCreateSchemaSQL($schemaName) |
|
187 | |||
188 | /** |
||
189 | * {@inheritDoc} |
||
190 | */ |
||
191 | 5430 | public function getDropForeignKeySQL($foreignKey, $table) |
|
206 | |||
207 | /** |
||
208 | * {@inheritDoc} |
||
209 | */ |
||
210 | 843 | public function getDropIndexSQL($index, $table = null) |
|
241 | |||
242 | /** |
||
243 | * {@inheritDoc} |
||
244 | */ |
||
245 | 7875 | protected function _getCreateTableSQL($tableName, array $columns, array $options = []) |
|
317 | |||
318 | /** |
||
319 | * {@inheritDoc} |
||
320 | */ |
||
321 | 6768 | public function getCreatePrimaryKeySQL(Index $index, $table) |
|
337 | |||
338 | /** |
||
339 | * Returns the SQL statement for creating a column comment. |
||
340 | * |
||
341 | * SQL Server does not support native column comments, |
||
342 | * therefore the extended properties functionality is used |
||
343 | * as a workaround to store them. |
||
344 | * The property name used to store column comments is "MS_Description" |
||
345 | * which provides compatibility with SQL Server Management Studio, |
||
346 | * as column comments are stored in the same property there when |
||
347 | * specifying a column's "Description" attribute. |
||
348 | * |
||
349 | * @param string $tableName The quoted table name to which the column belongs. |
||
350 | * @param string $columnName The quoted column name to create the comment for. |
||
351 | * @param string|null $comment The column's comment. |
||
352 | * |
||
353 | * @return string |
||
354 | */ |
||
355 | 7003 | protected function getCreateColumnCommentSQL($tableName, $columnName, $comment) |
|
377 | |||
378 | /** |
||
379 | * Returns the SQL snippet for declaring a default constraint. |
||
380 | * |
||
381 | * @param string $table Name of the table to return the default constraint declaration for. |
||
382 | * @param mixed[] $column Column definition. |
||
383 | * |
||
384 | * @return string |
||
385 | * |
||
386 | * @throws InvalidArgumentException |
||
387 | */ |
||
388 | 6905 | public function getDefaultConstraintDeclarationSQL($table, array $column) |
|
401 | |||
402 | /** |
||
403 | * {@inheritDoc} |
||
404 | */ |
||
405 | 5549 | public function getUniqueConstraintDeclarationSQL($name, Index $index) |
|
413 | |||
414 | /** |
||
415 | * {@inheritDoc} |
||
416 | */ |
||
417 | 7119 | public function getCreateIndexSQL(Index $index, $table) |
|
427 | |||
428 | /** |
||
429 | * {@inheritDoc} |
||
430 | */ |
||
431 | 7119 | protected function getCreateIndexSQLFlags(Index $index) |
|
446 | |||
447 | /** |
||
448 | * Extend unique key constraint with required filters |
||
449 | * |
||
450 | * @param string $sql |
||
451 | * |
||
452 | * @return string |
||
453 | */ |
||
454 | 5985 | private function _appendUniqueConstraintDefinition($sql, Index $index) |
|
464 | |||
465 | /** |
||
466 | * {@inheritDoc} |
||
467 | */ |
||
468 | 7033 | public function getAlterTableSQL(TableDiff $diff) |
|
630 | |||
631 | /** |
||
632 | * Returns the SQL clause for adding a default constraint in an ALTER TABLE statement. |
||
633 | * |
||
634 | * @param string $tableName The name of the table to generate the clause for. |
||
635 | * @param Column $column The column to generate the clause for. |
||
636 | * |
||
637 | * @return string |
||
638 | */ |
||
639 | 6816 | private function getAlterTableAddDefaultConstraintClause($tableName, Column $column) |
|
646 | |||
647 | /** |
||
648 | * Returns the SQL clause for dropping an existing default constraint in an ALTER TABLE statement. |
||
649 | * |
||
650 | * @param string $tableName The name of the table to generate the clause for. |
||
651 | * @param string $columnName The name of the column to generate the clause for. |
||
652 | * |
||
653 | * @return string |
||
654 | */ |
||
655 | 6813 | private function getAlterTableDropDefaultConstraintClause($tableName, $columnName) |
|
659 | |||
660 | /** |
||
661 | * Checks whether a column alteration requires dropping its default constraint first. |
||
662 | * |
||
663 | * Different to other database vendors SQL Server implements column default values |
||
664 | * as constraints and therefore changes in a column's default value as well as changes |
||
665 | * in a column's type require dropping the default constraint first before being to |
||
666 | * alter the particular column to the new definition. |
||
667 | * |
||
668 | * @param ColumnDiff $columnDiff The column diff to evaluate. |
||
669 | * |
||
670 | * @return bool True if the column alteration requires dropping its default constraint first, false otherwise. |
||
671 | */ |
||
672 | 6912 | private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff) |
|
696 | |||
697 | /** |
||
698 | * Returns the SQL statement for altering a column comment. |
||
699 | * |
||
700 | * SQL Server does not support native column comments, |
||
701 | * therefore the extended properties functionality is used |
||
702 | * as a workaround to store them. |
||
703 | * The property name used to store column comments is "MS_Description" |
||
704 | * which provides compatibility with SQL Server Management Studio, |
||
705 | * as column comments are stored in the same property there when |
||
706 | * specifying a column's "Description" attribute. |
||
707 | * |
||
708 | * @param string $tableName The quoted table name to which the column belongs. |
||
709 | * @param string $columnName The quoted column name to alter the comment for. |
||
710 | * @param string|null $comment The column's comment. |
||
711 | * |
||
712 | * @return string |
||
713 | */ |
||
714 | 6925 | protected function getAlterColumnCommentSQL($tableName, $columnName, $comment) |
|
736 | |||
737 | /** |
||
738 | * Returns the SQL statement for dropping a column comment. |
||
739 | * |
||
740 | * SQL Server does not support native column comments, |
||
741 | * therefore the extended properties functionality is used |
||
742 | * as a workaround to store them. |
||
743 | * The property name used to store column comments is "MS_Description" |
||
744 | * which provides compatibility with SQL Server Management Studio, |
||
745 | * as column comments are stored in the same property there when |
||
746 | * specifying a column's "Description" attribute. |
||
747 | * |
||
748 | * @param string $tableName The quoted table name to which the column belongs. |
||
749 | * @param string $columnName The quoted column name to drop the comment for. |
||
750 | * |
||
751 | * @return string |
||
752 | */ |
||
753 | 6946 | protected function getDropColumnCommentSQL($tableName, $columnName) |
|
774 | |||
775 | /** |
||
776 | * {@inheritdoc} |
||
777 | */ |
||
778 | 5554 | protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) |
|
788 | |||
789 | /** |
||
790 | * Returns the SQL statement for adding an extended property to a database object. |
||
791 | * |
||
792 | * @link http://msdn.microsoft.com/en-us/library/ms180047%28v=sql.90%29.aspx |
||
793 | * |
||
794 | * @param string $name The name of the property to add. |
||
795 | * @param string|null $value The value of the property to add. |
||
796 | * @param string|null $level0Type The type of the object at level 0 the property belongs to. |
||
797 | * @param string|null $level0Name The name of the object at level 0 the property belongs to. |
||
798 | * @param string|null $level1Type The type of the object at level 1 the property belongs to. |
||
799 | * @param string|null $level1Name The name of the object at level 1 the property belongs to. |
||
800 | * @param string|null $level2Type The type of the object at level 2 the property belongs to. |
||
801 | * @param string|null $level2Name The name of the object at level 2 the property belongs to. |
||
802 | * |
||
803 | * @return string |
||
804 | */ |
||
805 | 7003 | public function getAddExtendedPropertySQL( |
|
821 | |||
822 | /** |
||
823 | * Returns the SQL statement for dropping an extended property from a database object. |
||
824 | * |
||
825 | * @link http://technet.microsoft.com/en-gb/library/ms178595%28v=sql.90%29.aspx |
||
826 | * |
||
827 | * @param string $name The name of the property to drop. |
||
828 | * @param string|null $level0Type The type of the object at level 0 the property belongs to. |
||
829 | * @param string|null $level0Name The name of the object at level 0 the property belongs to. |
||
830 | * @param string|null $level1Type The type of the object at level 1 the property belongs to. |
||
831 | * @param string|null $level1Name The name of the object at level 1 the property belongs to. |
||
832 | * @param string|null $level2Type The type of the object at level 2 the property belongs to. |
||
833 | * @param string|null $level2Name The name of the object at level 2 the property belongs to. |
||
834 | * |
||
835 | * @return string |
||
836 | */ |
||
837 | 6946 | public function getDropExtendedPropertySQL( |
|
852 | |||
853 | /** |
||
854 | * Returns the SQL statement for updating an extended property of a database object. |
||
855 | * |
||
856 | * @link http://msdn.microsoft.com/en-us/library/ms186885%28v=sql.90%29.aspx |
||
857 | * |
||
858 | * @param string $name The name of the property to update. |
||
859 | * @param string|null $value The value of the property to update. |
||
860 | * @param string|null $level0Type The type of the object at level 0 the property belongs to. |
||
861 | * @param string|null $level0Name The name of the object at level 0 the property belongs to. |
||
862 | * @param string|null $level1Type The type of the object at level 1 the property belongs to. |
||
863 | * @param string|null $level1Name The name of the object at level 1 the property belongs to. |
||
864 | * @param string|null $level2Type The type of the object at level 2 the property belongs to. |
||
865 | * @param string|null $level2Name The name of the object at level 2 the property belongs to. |
||
866 | * |
||
867 | * @return string |
||
868 | */ |
||
869 | 6925 | public function getUpdateExtendedPropertySQL( |
|
885 | |||
886 | /** |
||
887 | * {@inheritDoc} |
||
888 | */ |
||
889 | 654 | public function getEmptyIdentityInsertSQL($quotedTableName, $quotedIdentifierColumnName) |
|
893 | |||
894 | /** |
||
895 | * {@inheritDoc} |
||
896 | */ |
||
897 | public function getListTablesSQL() |
||
903 | |||
904 | /** |
||
905 | * {@inheritDoc} |
||
906 | */ |
||
907 | 6511 | public function getListTableColumnsSQL($table, $database = null) |
|
936 | |||
937 | /** |
||
938 | * @param string $table |
||
939 | * @param string|null $database |
||
940 | * |
||
941 | * @return string |
||
942 | */ |
||
943 | 6469 | public function getListTableForeignKeysSQL($table, $database = null) |
|
961 | |||
962 | /** |
||
963 | * {@inheritDoc} |
||
964 | */ |
||
965 | 6427 | public function getListTableIndexesSQL($table, $currentDatabase = null) |
|
984 | |||
985 | /** |
||
986 | * {@inheritDoc} |
||
987 | */ |
||
988 | 831 | public function getCreateViewSQL($name, $sql) |
|
992 | |||
993 | /** |
||
994 | * {@inheritDoc} |
||
995 | */ |
||
996 | 831 | public function getListViewsSQL($database) |
|
1000 | |||
1001 | /** |
||
1002 | * Returns the where clause to filter schema and table name in a query. |
||
1003 | * |
||
1004 | * @param string $table The full qualified name of the table. |
||
1005 | * @param string $schemaColumn The name of the column to compare the schema to in the where clause. |
||
1006 | * @param string $tableColumn The name of the column to compare the table to in the where clause. |
||
1007 | * |
||
1008 | * @return string |
||
1009 | */ |
||
1010 | 6523 | private function getTableWhereClause($table, $schemaColumn, $tableColumn) |
|
1023 | |||
1024 | /** |
||
1025 | * {@inheritDoc} |
||
1026 | */ |
||
1027 | 831 | public function getDropViewSQL($name) |
|
1031 | |||
1032 | /** |
||
1033 | * {@inheritDoc} |
||
1034 | * |
||
1035 | * @deprecated Use application-generated UUIDs instead |
||
1036 | */ |
||
1037 | public function getGuidExpression() |
||
1041 | |||
1042 | /** |
||
1043 | * {@inheritDoc} |
||
1044 | */ |
||
1045 | 961 | public function getLocateExpression($str, $substr, $startPos = false) |
|
1053 | |||
1054 | /** |
||
1055 | * {@inheritDoc} |
||
1056 | */ |
||
1057 | public function getModExpression($expression1, $expression2) |
||
1061 | |||
1062 | /** |
||
1063 | * {@inheritDoc} |
||
1064 | */ |
||
1065 | 995 | public function getTrimExpression($str, $pos = TrimMode::UNSPECIFIED, $char = false) |
|
1105 | |||
1106 | /** |
||
1107 | * {@inheritDoc} |
||
1108 | */ |
||
1109 | 7432 | public function getConcatExpression() |
|
1115 | |||
1116 | /** |
||
1117 | * {@inheritDoc} |
||
1118 | */ |
||
1119 | 7611 | public function getListDatabasesSQL() |
|
1123 | |||
1124 | /** |
||
1125 | * {@inheritDoc} |
||
1126 | */ |
||
1127 | 859 | public function getListNamespacesSQL() |
|
1131 | |||
1132 | /** |
||
1133 | * {@inheritDoc} |
||
1134 | */ |
||
1135 | public function getSubstringExpression($value, $from, $length = null) |
||
1143 | |||
1144 | /** |
||
1145 | * {@inheritDoc} |
||
1146 | */ |
||
1147 | public function getLengthExpression($column) |
||
1151 | |||
1152 | /** |
||
1153 | * {@inheritDoc} |
||
1154 | */ |
||
1155 | 7409 | public function getSetTransactionIsolationSQL($level) |
|
1159 | |||
1160 | /** |
||
1161 | * {@inheritDoc} |
||
1162 | */ |
||
1163 | 7866 | public function getIntegerTypeDeclarationSQL(array $field) |
|
1167 | |||
1168 | /** |
||
1169 | * {@inheritDoc} |
||
1170 | */ |
||
1171 | 715 | public function getBigIntTypeDeclarationSQL(array $field) |
|
1175 | |||
1176 | /** |
||
1177 | * {@inheritDoc} |
||
1178 | */ |
||
1179 | 815 | public function getSmallIntTypeDeclarationSQL(array $field) |
|
1183 | |||
1184 | /** |
||
1185 | * {@inheritDoc} |
||
1186 | */ |
||
1187 | 6190 | public function getGuidTypeDeclarationSQL(array $field) |
|
1191 | |||
1192 | /** |
||
1193 | * {@inheritDoc} |
||
1194 | */ |
||
1195 | 7770 | protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) |
|
1199 | |||
1200 | /** |
||
1201 | * {@inheritdoc} |
||
1202 | */ |
||
1203 | 6774 | protected function getBinaryTypeDeclarationSQLSnippet($length, $fixed) |
|
1207 | |||
1208 | /** |
||
1209 | * {@inheritdoc} |
||
1210 | */ |
||
1211 | 6780 | public function getBinaryMaxLength() |
|
1215 | |||
1216 | /** |
||
1217 | * {@inheritDoc} |
||
1218 | */ |
||
1219 | 2512 | public function getClobTypeDeclarationSQL(array $field) |
|
1223 | |||
1224 | /** |
||
1225 | * {@inheritDoc} |
||
1226 | */ |
||
1227 | 7866 | protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) |
|
1231 | |||
1232 | /** |
||
1233 | * {@inheritDoc} |
||
1234 | */ |
||
1235 | public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration) |
||
1239 | |||
1240 | /** |
||
1241 | * {@inheritDoc} |
||
1242 | */ |
||
1243 | public function getDateTypeDeclarationSQL(array $fieldDeclaration) |
||
1247 | |||
1248 | /** |
||
1249 | * {@inheritDoc} |
||
1250 | */ |
||
1251 | public function getTimeTypeDeclarationSQL(array $fieldDeclaration) |
||
1255 | |||
1256 | /** |
||
1257 | * {@inheritDoc} |
||
1258 | */ |
||
1259 | 5918 | public function getBooleanTypeDeclarationSQL(array $field) |
|
1263 | |||
1264 | /** |
||
1265 | * {@inheritDoc} |
||
1266 | */ |
||
1267 | 7333 | protected function doModifyLimitQuery($query, $limit, $offset = null) |
|
1313 | |||
1314 | /** |
||
1315 | * Remove ORDER BY clauses in subqueries - they're not supported by SQL Server. |
||
1316 | * Caveat: will leave ORDER BY in TOP N subqueries. |
||
1317 | * |
||
1318 | * @param string $query |
||
1319 | * |
||
1320 | * @return string |
||
1321 | */ |
||
1322 | 7271 | private function scrubInnerOrderBy($query) |
|
1364 | |||
1365 | /** |
||
1366 | * Check an ORDER BY clause to see if it is in a TOP N query or subquery. |
||
1367 | * |
||
1368 | * @param string $query The query |
||
1369 | * @param int $currentPosition Start position of ORDER BY clause |
||
1370 | * |
||
1371 | * @return bool true if ORDER BY is in a TOP N query, false otherwise |
||
1372 | */ |
||
1373 | 7271 | private function isOrderByInTopNSubquery($query, $currentPosition) |
|
1396 | |||
1397 | /** |
||
1398 | * {@inheritDoc} |
||
1399 | */ |
||
1400 | 2415 | public function supportsLimitOffset() |
|
1404 | |||
1405 | /** |
||
1406 | * {@inheritDoc} |
||
1407 | */ |
||
1408 | 5918 | public function convertBooleans($item) |
|
1424 | |||
1425 | /** |
||
1426 | * {@inheritDoc} |
||
1427 | */ |
||
1428 | 719 | public function getCreateTemporaryTableSnippetSQL() |
|
1432 | |||
1433 | /** |
||
1434 | * {@inheritDoc} |
||
1435 | */ |
||
1436 | 719 | public function getTemporaryTableName($tableName) |
|
1440 | |||
1441 | /** |
||
1442 | * {@inheritDoc} |
||
1443 | */ |
||
1444 | public function getDateTimeFormatString() |
||
1448 | |||
1449 | /** |
||
1450 | * {@inheritDoc} |
||
1451 | */ |
||
1452 | public function getDateFormatString() |
||
1456 | |||
1457 | /** |
||
1458 | * {@inheritDoc} |
||
1459 | */ |
||
1460 | public function getTimeFormatString() |
||
1464 | |||
1465 | /** |
||
1466 | * {@inheritDoc} |
||
1467 | */ |
||
1468 | public function getDateTimeTzFormatString() |
||
1472 | |||
1473 | /** |
||
1474 | * {@inheritDoc} |
||
1475 | */ |
||
1476 | 3212 | public function getName() |
|
1480 | |||
1481 | /** |
||
1482 | * {@inheritDoc} |
||
1483 | */ |
||
1484 | 6898 | protected function initializeDoctrineTypeMappings() |
|
1514 | |||
1515 | /** |
||
1516 | * {@inheritDoc} |
||
1517 | */ |
||
1518 | 1005 | public function createSavePoint($savepoint) |
|
1522 | |||
1523 | /** |
||
1524 | * {@inheritDoc} |
||
1525 | */ |
||
1526 | public function releaseSavePoint($savepoint) |
||
1530 | |||
1531 | /** |
||
1532 | * {@inheritDoc} |
||
1533 | */ |
||
1534 | 1005 | public function rollbackSavePoint($savepoint) |
|
1538 | |||
1539 | /** |
||
1540 | * {@inheritdoc} |
||
1541 | */ |
||
1542 | 6257 | public function getForeignKeyReferentialActionSQL($action) |
|
1551 | |||
1552 | /** |
||
1553 | * {@inheritDoc} |
||
1554 | */ |
||
1555 | 3250 | public function appendLockHint($fromClause, $lockMode) |
|
1571 | |||
1572 | /** |
||
1573 | * {@inheritDoc} |
||
1574 | */ |
||
1575 | 723 | public function getForUpdateSQL() |
|
1579 | |||
1580 | /** |
||
1581 | * {@inheritDoc} |
||
1582 | */ |
||
1583 | 2131 | protected function getReservedKeywordsClass() |
|
1587 | |||
1588 | /** |
||
1589 | * {@inheritDoc} |
||
1590 | */ |
||
1591 | 7343 | public function quoteSingleIdentifier($str) |
|
1595 | |||
1596 | /** |
||
1597 | * {@inheritDoc} |
||
1598 | */ |
||
1599 | 5729 | public function getTruncateTableSQL($tableName, $cascade = false) |
|
1605 | |||
1606 | /** |
||
1607 | * {@inheritDoc} |
||
1608 | */ |
||
1609 | 6965 | public function getBlobTypeDeclarationSQL(array $field) |
|
1613 | |||
1614 | /** |
||
1615 | * {@inheritdoc} |
||
1616 | * |
||
1617 | * Modifies column declaration order as it differs in Microsoft SQL Server. |
||
1618 | */ |
||
1619 | 7917 | public function getColumnDeclarationSQL($name, array $field) |
|
1641 | |||
1642 | /** |
||
1643 | * Returns a unique default constraint name for a table and column. |
||
1644 | * |
||
1645 | * @param string $table Name of the table to generate the unique default constraint name for. |
||
1646 | * @param string $column Name of the column in the table to generate the unique default constraint name for. |
||
1647 | * |
||
1648 | * @return string |
||
1649 | */ |
||
1650 | 6905 | private function generateDefaultConstraintName($table, $column) |
|
1654 | |||
1655 | /** |
||
1656 | * Returns a hash value for a given identifier. |
||
1657 | * |
||
1658 | * @param string $identifier Identifier to generate a hash value for. |
||
1659 | * |
||
1660 | * @return string |
||
1661 | */ |
||
1662 | 6908 | private function generateIdentifierName($identifier) |
|
1669 | |||
1670 | 767 | protected function getCommentOnTableSQL(string $tableName, ?string $comment) : string |
|
1683 | |||
1684 | 898 | public function getListTableMetadataSQL(string $table) : string |
|
1700 | } |
||
1701 |
This error can happen if you refactor code and forget to move the variable initialization.
Let’s take a look at a simple example:
The above code is perfectly fine. Now imagine that we re-order the statements:
In that case,
$x
would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.