@@ -223,7 +223,7 @@ |
||
223 | 223 | { |
224 | 224 | $columns = array_filter( |
225 | 225 | $this->getColumns(), |
226 | - function ($column) use ($name) { |
|
226 | + function($column) use ($name) { |
|
227 | 227 | return $column->getName() === $name; |
228 | 228 | } |
229 | 229 | ); |
@@ -1242,7 +1242,7 @@ |
||
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | $order = $index->getOrder() ?? []; |
1245 | - $columnNames = array_map(function ($columnName) use ($order) { |
|
1245 | + $columnNames = array_map(function($columnName) use ($order) { |
|
1246 | 1246 | $ret = '"' . $columnName . '"'; |
1247 | 1247 | if (isset($order[$columnName])) { |
1248 | 1248 | $ret .= ' ' . $order[$columnName]; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $options = $table->getOptions(); |
202 | 202 | $parts = $this->getSchemaName($table->getName()); |
203 | 203 | |
204 | - // Add the default primary key |
|
204 | + // Add the default primary key |
|
205 | 205 | if (!isset($options['id']) || (isset($options['id']) && $options['id'] === true)) { |
206 | 206 | $options['id'] = 'id'; |
207 | 207 | } |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | // Handle id => "field_name" to support AUTO_INCREMENT |
211 | 211 | $column = new Column(); |
212 | 212 | $column->setName($options['id']) |
213 | - ->setType('integer') |
|
214 | - ->setOptions(['identity' => true]); |
|
213 | + ->setType('integer') |
|
214 | + ->setOptions(['identity' => true]); |
|
215 | 215 | |
216 | 216 | array_unshift($columns, $column); |
217 | 217 | if (isset($options['primary_key']) && (array)$options['id'] !== (array)$options['primary_key']) { |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | - // set the primary key(s) |
|
237 | + // set the primary key(s) |
|
238 | 238 | if (isset($options['primary_key'])) { |
239 | 239 | $sql = rtrim($sql); |
240 | 240 | $sql .= sprintf(' CONSTRAINT %s PRIMARY KEY (', $this->quoteColumnName($parts['table'] . '_pkey')); |
@@ -429,11 +429,11 @@ discard block |
||
429 | 429 | |
430 | 430 | $column = new Column(); |
431 | 431 | $column->setName($columnInfo['column_name']) |
432 | - ->setType($columnType) |
|
433 | - ->setNull($columnInfo['is_nullable'] === 'YES') |
|
434 | - ->setDefault($columnDefault) |
|
435 | - ->setIdentity($columnInfo['is_identity'] === 'YES') |
|
436 | - ->setScale($columnInfo['numeric_scale']); |
|
432 | + ->setType($columnType) |
|
433 | + ->setNull($columnInfo['is_nullable'] === 'YES') |
|
434 | + ->setDefault($columnDefault) |
|
435 | + ->setIdentity($columnInfo['is_identity'] === 'YES') |
|
436 | + ->setScale($columnInfo['numeric_scale']); |
|
437 | 437 | |
438 | 438 | if (preg_match('/\bwith time zone$/', $columnInfo['data_type'])) { |
439 | 439 | $column->setTimezone(true); |
@@ -312,7 +312,7 @@ |
||
312 | 312 | $sql .= '(' . implode(', ', array_map([$this, 'quoteColumnName'], $keys)) . ') VALUES '; |
313 | 313 | |
314 | 314 | if ($this->isDryRunEnabled()) { |
315 | - $values = array_map(function ($row) { |
|
315 | + $values = array_map(function($row) { |
|
316 | 316 | return '(' . implode(', ', array_map([$this, 'quoteValue'], $row)) . ')'; |
317 | 317 | }, $rows); |
318 | 318 | $sql .= implode(', ', $values) . ';'; |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | PCRE_PATTERN; |
550 | 550 | preg_match_all($pattern, $v, $matches); |
551 | 551 | // strip out any comment tokens |
552 | - $matches = array_map(function ($v) { |
|
552 | + $matches = array_map(function($v) { |
|
553 | 553 | return preg_match('/^(?:\/\*|--)/', $v) ? ' ' : $v; |
554 | 554 | }, $matches[0]); |
555 | 555 | // reconstitute the string, trimming whitespace as well as parentheses |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | |
689 | 689 | $instructions = $this->beginAlterByCopyTable($tableName); |
690 | 690 | |
691 | - $instructions->addPostStep(function ($state) use ($tableName, $column) { |
|
691 | + $instructions->addPostStep(function($state) use ($tableName, $column) { |
|
692 | 692 | // we use the final column to anchor our regex to insert the new column, |
693 | 693 | // as the alternative is unwinding all possible table constraints which |
694 | 694 | // gets messy quickly with CHECK constraints. |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | return $state; |
713 | 713 | }); |
714 | 714 | |
715 | - $instructions->addPostStep(function ($state) use ($tableName) { |
|
715 | + $instructions->addPostStep(function($state) use ($tableName) { |
|
716 | 716 | $newState = $this->calculateNewTableColumns($tableName, false, false); |
717 | 717 | |
718 | 718 | return $newState + $state; |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | */ |
797 | 797 | protected function copyAndDropTmpTable($instructions, $tableName) |
798 | 798 | { |
799 | - $instructions->addPostStep(function ($state) use ($tableName) { |
|
799 | + $instructions->addPostStep(function($state) use ($tableName) { |
|
800 | 800 | $this->copyDataToNewTable( |
801 | 801 | $state['tmpTableName'], |
802 | 802 | $tableName, |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | protected function beginAlterByCopyTable($tableName) |
878 | 878 | { |
879 | 879 | $instructions = new AlterInstructions(); |
880 | - $instructions->addPostStep(function ($state) use ($tableName) { |
|
880 | + $instructions->addPostStep(function($state) use ($tableName) { |
|
881 | 881 | $tmpTableName = "tmp_{$tableName}"; |
882 | 882 | $createSQL = $this->getDeclaringSql($tableName); |
883 | 883 | |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | { |
910 | 910 | $instructions = $this->beginAlterByCopyTable($tableName); |
911 | 911 | |
912 | - $instructions->addPostStep(function ($state) use ($columnName, $newColumnName) { |
|
912 | + $instructions->addPostStep(function($state) use ($columnName, $newColumnName) { |
|
913 | 913 | $sql = str_replace( |
914 | 914 | $this->quoteColumnName($columnName), |
915 | 915 | $this->quoteColumnName($newColumnName), |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | return $state; |
921 | 921 | }); |
922 | 922 | |
923 | - $instructions->addPostStep(function ($state) use ($columnName, $newColumnName, $tableName) { |
|
923 | + $instructions->addPostStep(function($state) use ($columnName, $newColumnName, $tableName) { |
|
924 | 924 | $newState = $this->calculateNewTableColumns($tableName, $columnName, $newColumnName); |
925 | 925 | |
926 | 926 | return $newState + $state; |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | $instructions = $this->beginAlterByCopyTable($tableName); |
938 | 938 | |
939 | 939 | $newColumnName = $newColumn->getName(); |
940 | - $instructions->addPostStep(function ($state) use ($columnName, $newColumn) { |
|
940 | + $instructions->addPostStep(function($state) use ($columnName, $newColumn) { |
|
941 | 941 | $sql = preg_replace( |
942 | 942 | sprintf("/%s(?:\/\*.*?\*\/|\([^)]+\)|'[^']*?'|[^,])+([,)])/", $this->quoteColumnName($columnName)), |
943 | 943 | sprintf('%s %s$1', $this->quoteColumnName($newColumn->getName()), $this->getColumnSqlDefinition($newColumn)), |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | return $state; |
950 | 950 | }); |
951 | 951 | |
952 | - $instructions->addPostStep(function ($state) use ($columnName, $newColumnName, $tableName) { |
|
952 | + $instructions->addPostStep(function($state) use ($columnName, $newColumnName, $tableName) { |
|
953 | 953 | $newState = $this->calculateNewTableColumns($tableName, $columnName, $newColumnName); |
954 | 954 | |
955 | 955 | return $newState + $state; |
@@ -965,13 +965,13 @@ discard block |
||
965 | 965 | { |
966 | 966 | $instructions = $this->beginAlterByCopyTable($tableName); |
967 | 967 | |
968 | - $instructions->addPostStep(function ($state) use ($tableName, $columnName) { |
|
968 | + $instructions->addPostStep(function($state) use ($tableName, $columnName) { |
|
969 | 969 | $newState = $this->calculateNewTableColumns($tableName, $columnName, false); |
970 | 970 | |
971 | 971 | return $newState + $state; |
972 | 972 | }); |
973 | 973 | |
974 | - $instructions->addPostStep(function ($state) use ($columnName) { |
|
974 | + $instructions->addPostStep(function($state) use ($columnName) { |
|
975 | 975 | $sql = preg_replace( |
976 | 976 | sprintf("/%s\s%s.*(,\s(?!')|\)$)/U", preg_quote($this->quoteColumnName($columnName)), preg_quote($state['columnType'])), |
977 | 977 | '', |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | $instructions = $this->beginAlterByCopyTable($table->getName()); |
1239 | 1239 | |
1240 | 1240 | $tableName = $table->getName(); |
1241 | - $instructions->addPostStep(function ($state) use ($column) { |
|
1241 | + $instructions->addPostStep(function($state) use ($column) { |
|
1242 | 1242 | $matchPattern = "/(`$column`)\s+(\w+(\(\d+\))?)\s+((NOT )?NULL)/"; |
1243 | 1243 | |
1244 | 1244 | $sql = $state['createSQL']; |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | return $state; |
1261 | 1261 | }); |
1262 | 1262 | |
1263 | - $instructions->addPostStep(function ($state) { |
|
1263 | + $instructions->addPostStep(function($state) { |
|
1264 | 1264 | $columns = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($state['tmpTableName']))); |
1265 | 1265 | $names = array_map([$this, 'quoteColumnName'], array_column($columns, 'name')); |
1266 | 1266 | $selectColumns = $writeColumns = $names; |
@@ -1281,7 +1281,7 @@ discard block |
||
1281 | 1281 | { |
1282 | 1282 | $instructions = $this->beginAlterByCopyTable($table->getName()); |
1283 | 1283 | |
1284 | - $instructions->addPostStep(function ($state) { |
|
1284 | + $instructions->addPostStep(function($state) { |
|
1285 | 1285 | $search = "/(,?\s*PRIMARY KEY\s*\([^\)]*\)|\s+PRIMARY KEY(\s+AUTOINCREMENT)?)/"; |
1286 | 1286 | $sql = preg_replace($search, '', $state['createSQL'], 1); |
1287 | 1287 | |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | return $state; |
1293 | 1293 | }); |
1294 | 1294 | |
1295 | - $instructions->addPostStep(function ($state) use ($column) { |
|
1295 | + $instructions->addPostStep(function($state) use ($column) { |
|
1296 | 1296 | $newState = $this->calculateNewTableColumns($state['tmpTableName'], $column, $column); |
1297 | 1297 | |
1298 | 1298 | return $newState + $state; |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | $instructions = $this->beginAlterByCopyTable($table->getName()); |
1310 | 1310 | |
1311 | 1311 | $tableName = $table->getName(); |
1312 | - $instructions->addPostStep(function ($state) use ($foreignKey, $tableName) { |
|
1312 | + $instructions->addPostStep(function($state) use ($foreignKey, $tableName) { |
|
1313 | 1313 | $this->execute('pragma foreign_keys = ON'); |
1314 | 1314 | $sql = substr($state['createSQL'], 0, -1) . ',' . $this->getForeignKeySqlDefinition($foreignKey) . '); '; |
1315 | 1315 | |
@@ -1336,7 +1336,7 @@ discard block |
||
1336 | 1336 | return $state; |
1337 | 1337 | }); |
1338 | 1338 | |
1339 | - $instructions->addPostStep(function ($state) { |
|
1339 | + $instructions->addPostStep(function($state) { |
|
1340 | 1340 | $columns = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($state['tmpTableName']))); |
1341 | 1341 | $names = array_map([$this, 'quoteColumnName'], array_column($columns, 'name')); |
1342 | 1342 | $selectColumns = $writeColumns = $names; |
@@ -1368,7 +1368,7 @@ discard block |
||
1368 | 1368 | { |
1369 | 1369 | $instructions = $this->beginAlterByCopyTable($tableName); |
1370 | 1370 | |
1371 | - $instructions->addPostStep(function ($state) use ($columns) { |
|
1371 | + $instructions->addPostStep(function($state) use ($columns) { |
|
1372 | 1372 | $sql = ''; |
1373 | 1373 | |
1374 | 1374 | foreach ($columns as $columnName) { |
@@ -1386,7 +1386,7 @@ discard block |
||
1386 | 1386 | return $state; |
1387 | 1387 | }); |
1388 | 1388 | |
1389 | - $instructions->addPostStep(function ($state) use ($columns) { |
|
1389 | + $instructions->addPostStep(function($state) use ($columns) { |
|
1390 | 1390 | $newState = $this->calculateNewTableColumns($state['tmpTableName'], $columns[0], $columns[0]); |
1391 | 1391 | |
1392 | 1392 | $selectColumns = $newState['selectColumns']; |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | // Handle id => "field_name" to support AUTO_INCREMENT |
371 | 371 | $column = new Column(); |
372 | 372 | $column->setName($options['id']) |
373 | - ->setType('integer') |
|
374 | - ->setOptions(['identity' => true]); |
|
373 | + ->setType('integer') |
|
374 | + ->setOptions(['identity' => true]); |
|
375 | 375 | |
376 | 376 | array_unshift($columns, $column); |
377 | 377 | } |
@@ -651,12 +651,12 @@ discard block |
||
651 | 651 | $default = $this->parseDefaultValue($columnInfo['dflt_value'], $type['name']); |
652 | 652 | |
653 | 653 | $column->setName($columnInfo['name']) |
654 | - ->setNull($columnInfo['notnull'] !== '1') |
|
655 | - ->setDefault($default) |
|
656 | - ->setType($type['name']) |
|
657 | - ->setLimit($type['limit']) |
|
658 | - ->setScale($type['scale']) |
|
659 | - ->setIdentity($columnInfo['name'] === $identity); |
|
654 | + ->setNull($columnInfo['notnull'] !== '1') |
|
655 | + ->setDefault($default) |
|
656 | + ->setType($type['name']) |
|
657 | + ->setLimit($type['limit']) |
|
658 | + ->setScale($type['scale']) |
|
659 | + ->setIdentity($columnInfo['name'] === $identity); |
|
660 | 660 | |
661 | 661 | $columns[] = $column; |
662 | 662 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $env = $this->getEnvironment($environment); |
122 | 122 | $versions = $env->getVersionLog(); |
123 | 123 | |
124 | - $maxNameLength = $versions ? max(array_map(function ($version) { |
|
124 | + $maxNameLength = $versions ? max(array_map(function($version) { |
|
125 | 125 | return strlen($version['migration_name']); |
126 | 126 | }, $versions)) : 0; |
127 | 127 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $versions = array_keys($this->getMigrations($environment)); |
286 | 286 | $dateString = $dateTime->format('YmdHis'); |
287 | 287 | |
288 | - $outstandingMigrations = array_filter($versions, function ($version) use ($dateString) { |
|
288 | + $outstandingMigrations = array_filter($versions, function($version) use ($dateString) { |
|
289 | 289 | return $version <= $dateString; |
290 | 290 | }); |
291 | 291 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | $target = 0; |
464 | 464 | } elseif (!is_numeric($target) && $target !== null) { // try to find a target version based on name |
465 | 465 | // search through the migrations using the name |
466 | - $migrationNames = array_map(function ($item) { |
|
466 | + $migrationNames = array_map(function($item) { |
|
467 | 467 | return $item['migration_name']; |
468 | 468 | }, $executedVersions); |
469 | 469 | $found = array_search($target, $migrationNames, true); |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | $this->getOutput()->writeln('Migration file'); |
709 | 709 | $this->getOutput()->writeln( |
710 | 710 | array_map( |
711 | - function ($phpFile) { |
|
711 | + function($phpFile) { |
|
712 | 712 | return " <info>{$phpFile}</info>"; |
713 | 713 | }, |
714 | 714 | $phpFiles |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public static function mapClassNameToFileName($className) |
106 | 106 | { |
107 | - $snake = function ($matches) { |
|
107 | + $snake = function($matches) { |
|
108 | 108 | return '_' . strtolower($matches[0]); |
109 | 109 | }; |
110 | 110 | $fileName = preg_replace_callback('/\d+|[A-Z]/', $snake, $className); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public static function getFiles($paths) |
274 | 274 | { |
275 | - $files = static::globAll(array_map(function ($path) { |
|
275 | + $files = static::globAll(array_map(function($path) { |
|
276 | 276 | return $path . DIRECTORY_SEPARATOR . "*.php"; |
277 | 277 | }, (array)$paths)); |
278 | 278 | // glob() can return the same file multiple times |
@@ -56,7 +56,7 @@ |
||
56 | 56 | sprintf('%s %s', str_repeat('=', $maxAliasLength), str_repeat('=', $maxClassLength)), |
57 | 57 | ], |
58 | 58 | array_map( |
59 | - function ($alias, $class) use ($maxAliasLength, $maxClassLength) { |
|
59 | + function($alias, $class) use ($maxAliasLength, $maxClassLength) { |
|
60 | 60 | return sprintf('%s %s', str_pad($alias, $maxAliasLength), str_pad($class, $maxClassLength)); |
61 | 61 | }, |
62 | 62 | array_keys($aliases), |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | // Handle id => "field_name" to support AUTO_INCREMENT |
268 | 268 | $column = new Column(); |
269 | 269 | $column->setName($options['id']) |
270 | - ->setType('integer') |
|
271 | - ->setOptions([ |
|
272 | - 'signed' => $options['signed'] ?? false, |
|
273 | - 'identity' => true, |
|
274 | - ]); |
|
270 | + ->setType('integer') |
|
271 | + ->setOptions([ |
|
272 | + 'signed' => $options['signed'] ?? false, |
|
273 | + 'identity' => true, |
|
274 | + ]); |
|
275 | 275 | |
276 | 276 | array_unshift($columns, $column); |
277 | 277 | if (isset($options['primary_key']) && (array)$options['id'] !== (array)$options['primary_key']) { |
@@ -442,12 +442,12 @@ discard block |
||
442 | 442 | |
443 | 443 | $column = new Column(); |
444 | 444 | $column->setName($columnInfo['Field']) |
445 | - ->setNull($columnInfo['Null'] !== 'NO') |
|
446 | - ->setDefault($columnInfo['Default']) |
|
447 | - ->setType($phinxType['name']) |
|
448 | - ->setSigned(strpos($columnInfo['Type'], 'unsigned') === false) |
|
449 | - ->setLimit($phinxType['limit']) |
|
450 | - ->setScale($phinxType['scale']); |
|
445 | + ->setNull($columnInfo['Null'] !== 'NO') |
|
446 | + ->setDefault($columnInfo['Default']) |
|
447 | + ->setType($phinxType['name']) |
|
448 | + ->setSigned(strpos($columnInfo['Type'], 'unsigned') === false) |
|
449 | + ->setLimit($phinxType['limit']) |
|
450 | + ->setScale($phinxType['scale']); |
|
451 | 451 | |
452 | 452 | if ($columnInfo['Extra'] === 'auto_increment') { |
453 | 453 | $column->setIdentity(true); |
@@ -1311,7 +1311,7 @@ discard block |
||
1311 | 1311 | $def .= '(' . $sqlType['limit'] . ')'; |
1312 | 1312 | } |
1313 | 1313 | if (($values = $column->getValues()) && is_array($values)) { |
1314 | - $def .= "(" . implode(", ", array_map(function ($value) { |
|
1314 | + $def .= "(" . implode(", ", array_map(function($value) { |
|
1315 | 1315 | // we special case NULL as it's not actually allowed an enum value, |
1316 | 1316 | // and we want MySQL to issue an error on the create statement, but |
1317 | 1317 | // quote coerces it to an empty string, which will not error |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | if (!empty($columnNames)) { |
1383 | 1383 | foreach ($columnNames as $key => $value) { |
1384 | 1384 | $loc = array_search($key, $columnNames); |
1385 | - $columnNames[$key] = is_array($order) && array_key_exists($value, $order) ? sprintf('`%s` %s', $value, $order[$value]) : sprintf('`%s`', $value); |
|
1385 | + $columnNames[$key] = is_array($order) && array_key_exists($value, $order) ? sprintf('`%s` %s', $value, $order[$value]) : sprintf('`%s`', $value); |
|
1386 | 1386 | } |
1387 | 1387 | } |
1388 | 1388 |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | // Handle id => "field_name" to support AUTO_INCREMENT |
236 | 236 | $column = new Column(); |
237 | 237 | $column->setName($options['id']) |
238 | - ->setType('integer') |
|
239 | - ->setOptions(['identity' => true]); |
|
238 | + ->setType('integer') |
|
239 | + ->setOptions(['identity' => true]); |
|
240 | 240 | |
241 | 241 | array_unshift($columns, $column); |
242 | 242 | if (isset($options['primary_key']) && (array)$options['id'] !== (array)$options['primary_key']) { |
@@ -465,11 +465,11 @@ discard block |
||
465 | 465 | |
466 | 466 | $column = new Column(); |
467 | 467 | $column->setName($columnInfo['name']) |
468 | - ->setType($type) |
|
469 | - ->setNull($columnInfo['null'] !== 'NO') |
|
470 | - ->setDefault($this->parseDefault($columnInfo['default'])) |
|
471 | - ->setIdentity($columnInfo['identity'] === '1') |
|
472 | - ->setComment($this->getColumnComment($columnInfo['table_name'], $columnInfo['name'])); |
|
468 | + ->setType($type) |
|
469 | + ->setNull($columnInfo['null'] !== 'NO') |
|
470 | + ->setDefault($this->parseDefault($columnInfo['default'])) |
|
471 | + ->setIdentity($columnInfo['identity'] === '1') |
|
472 | + ->setComment($this->getColumnComment($columnInfo['table_name'], $columnInfo['name'])); |
|
473 | 473 | |
474 | 474 | if (!empty($columnInfo['char_length'])) { |
475 | 475 | $column->setLimit($columnInfo['char_length']); |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | |
792 | 792 | foreach ($indexes as $name => $index) { |
793 | 793 | if ($name === $indexName) { |
794 | - return true; |
|
794 | + return true; |
|
795 | 795 | } |
796 | 796 | } |
797 | 797 |