GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#14)
by
unknown
01:39
created
console/components/Formatter.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
     public function getTableName($table)
45 45
     {
46
-        return '{{%' . str_replace($this->db->tablePrefix, '', $table->name) . '}}';
46
+        return '{{%'.str_replace($this->db->tablePrefix, '', $table->name).'}}';
47 47
     }
48 48
 
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     {
53 53
 
54 54
         
55
-        return '$this->batchInsert("{{%test}}", ' . $rows . ', ' . $columns . ');';
55
+        return '$this->batchInsert("{{%test}}", '.$rows.', '.$columns.');';
56 56
     }
57 57
 
58 58
     /**
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
         foreach ($data as $row) {
77 77
             $rows = '';
78 78
             foreach ($row as $value) {
79
-                $rows .= "'" . addslashes($value) . "',";
79
+                $rows .= "'".addslashes($value)."',";
80 80
             }
81
-            self::$rows .= "\n\t\t\t" . self::dataFormat($rows) . ",";
81
+            self::$rows .= "\n\t\t\t".self::dataFormat($rows).",";
82 82
         }
83 83
         if (!empty(self::$rows)) {
84 84
             return self::dataFormat(self::$rows);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         if (null !== $trim) {
97 97
             $data = rtrim($data, $trim);
98 98
         }
99
-        return self::$dataEncloser[0] . $data . self::$dataEncloser[1];
99
+        return self::$dataEncloser[0].$data.self::$dataEncloser[1];
100 100
     }
101 101
 
102 102
     /**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             $data = rtrim($data, $trim);
111 111
         }
112 112
 
113
-        return self::$columnEncloser[0] . rtrim($data, $trim) . self::$columnEncloser[1];
113
+        return self::$columnEncloser[0].rtrim($data, $trim).self::$columnEncloser[1];
114 114
     }
115 115
 
116 116
     /**
Please login to merge, or discard this patch.
Braces   +23 added lines, -25 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  * Table class
7 7
  */
8
-trait Formatter
9
-{
8
+trait Formatter {
10 9
 
11 10
     /**
12 11
      * @var array column enclosing literal
@@ -41,15 +40,13 @@  discard block
 block discarded – undo
41 40
      * @author Tarun Mukherjee (https://github.com/tmukherjee13)
42 41
      */
43 42
 
44
-    public function getTableName($table)
45
-    {
43
+    public function getTableName($table) {
46 44
         return '{{%' . str_replace($this->db->tablePrefix, '', $table->name) . '}}';
47 45
     }
48 46
 
49 47
 
50 48
     
51
-    public function prepareInsert($rows, $columns)
52
-    {
49
+    public function prepareInsert($rows, $columns) {
53 50
 
54 51
         
55 52
         return '$this->batchInsert("{{%test}}", ' . $rows . ', ' . $columns . ');';
@@ -60,8 +57,7 @@  discard block
 block discarded – undo
60 57
      * @param string $data the column string|$trim the literal to trim
61 58
      * @return string
62 59
      */
63
-    public function prepareColumns($data, $trim = ',')
64
-    {
60
+    public function prepareColumns($data, $trim = ',') {
65 61
         return self::columnFormat($data, $trim);
66 62
     }
67 63
 
@@ -70,8 +66,7 @@  discard block
 block discarded – undo
70 66
      * @param array $data the data array
71 67
      * @return string
72 68
      */
73
-    public function prepareData($data = [])
74
-    {
69
+    public function prepareData($data = []) {
75 70
         self::$rows = '';
76 71
         foreach ($data as $row) {
77 72
             $rows = '';
@@ -91,8 +86,7 @@  discard block
 block discarded – undo
91 86
      * @param string $data the column string|$trim the literal to trim
92 87
      * @return string
93 88
      */
94
-    public function dataFormat($data, $trim = ',')
95
-    {
89
+    public function dataFormat($data, $trim = ',') {
96 90
         if (null !== $trim) {
97 91
             $data = rtrim($data, $trim);
98 92
         }
@@ -104,8 +98,7 @@  discard block
 block discarded – undo
104 98
      * @param string $data the column string|$trim the literal to trim
105 99
      * @return string
106 100
      */
107
-    public function columnFormat($data, $trim = ',')
108
-    {
101
+    public function columnFormat($data, $trim = ',') {
109 102
         if (null !== $trim) {
110 103
             $data = rtrim($data, $trim);
111 104
         }
@@ -122,8 +115,7 @@  discard block
 block discarded – undo
122 115
      * @author Tarun Mukherjee (https://github.com/tmukherjee13)
123 116
      */
124 117
 
125
-    public function getColType($col)
126
-    {
118
+    public function getColType($col) {
127 119
 
128 120
         if ($col->isPrimaryKey && $col->autoIncrement) {
129 121
             return 'pk';
@@ -135,11 +127,14 @@  discard block
 block discarded – undo
135 127
         }
136 128
         if ($col->defaultValue != null && 'timestamp' != $col->dbType) {
137 129
             $result .= " DEFAULT '{$col->defaultValue}'";
138
-        } elseif ($col->defaultValue == 'CURRENT_TIMESTAMP' && 'timestamp' == $col->dbType) {
130
+        }
131
+        elseif ($col->defaultValue == 'CURRENT_TIMESTAMP' && 'timestamp' == $col->dbType) {
139 132
             $result .= " DEFAULT {$col->defaultValue}";
140
-        } elseif ($col->defaultValue != null && 'timestamp' == $col->dbType) {
133
+        }
134
+        elseif ($col->defaultValue != null && 'timestamp' == $col->dbType) {
141 135
             $result .= " DEFAULT '{$col->defaultValue}'";
142
-        } elseif ($col->allowNull) {
136
+        }
137
+        elseif ($col->allowNull) {
143 138
             $result .= ' DEFAULT NULL';
144 139
         }
145 140
         return $result;
@@ -167,19 +162,22 @@  discard block
 block discarded – undo
167 162
      * @author Tarun Mukherjee (https://github.com/tmukherjee13)
168 163
      */
169 164
 
170
-    public function formatCol($col)
171
-    {
165
+    public function formatCol($col) {
172 166
         $decorator = [];
173 167
         if ($col->isPrimaryKey && $col->autoIncrement) {
174 168
             $decorator[] = 'primaryKey';
175
-        } elseif (in_array($col->type, self::$colTypes)) {
169
+        }
170
+        elseif (in_array($col->type, self::$colTypes)) {
176 171
             $decorator[] = "{$this->modifyColType($col->dbType)}";
177
-        } elseif ($col->type == 'decimal') {
172
+        }
173
+        elseif ($col->type == 'decimal') {
178 174
             $decorator[] = "{$col->dbType}";
179
-        } else {
175
+        }
176
+        else {
180 177
             if (!empty($col->size) && $col->size == 1 && $col->type != 'char') {
181 178
                 $column = "boolean";
182
-            } else {
179
+            }
180
+            else {
183 181
                 $column = "{$col->type}";
184 182
                 if (!empty($col->size)) {
185 183
                     $column .= "({$col->size})";
Please login to merge, or discard this patch.
views/_createTable.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,9 +13,11 @@
 block discarded – undo
13 13
     if (empty($field['decorators'])): ?>
14 14
             '<?= $field['property'] ?>',
15 15
 
16
-<?php else: ?>
16
+<?php else {
17
+    : ?>
17 18
             <?= "'{$field['property']}' => \$this->{$field['decorators']}" ?>,
18 19
 <?php endif;
20
+}
19 21
 
20 22
 endforeach; ?>
21 23
 
Please login to merge, or discard this patch.
console/controllers/MigrationController.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                 throw new Exception("The 'db' option must refer to the application component ID of a DB connection.");
90 90
             }
91 91
 
92
-            $path = (string)Yii::getAlias($this->migrationPath);
92
+            $path = (string) Yii::getAlias($this->migrationPath);
93 93
 
94 94
 
95 95
             if (!is_dir($path)) {
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     protected function getCreateTableSql($table)
186 186
     {
187
-        $row = $this->db->createCommand('SHOW CREATE TABLE ' . $this->quoteTableName($table->fullName))->queryOne();
187
+        $row = $this->db->createCommand('SHOW CREATE TABLE '.$this->quoteTableName($table->fullName))->queryOne();
188 188
         if (isset($row['Create Table'])) {
189 189
             $sql = $row['Create Table'];
190 190
         } else {
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public function actionUpData($limit = 0)
209 209
     {
210
-        $this->migrationPath .= DIRECTORY_SEPARATOR . $this->dataMigrationFolder;
210
+        $this->migrationPath .= DIRECTORY_SEPARATOR.$this->dataMigrationFolder;
211 211
         return parent::actionUp($limit);
212 212
     }
213 213
 
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
     public function actionTable(array $tables)
223 223
     {
224 224
 
225
-        if ($this->confirm('Create the migration ' . "?")) {
225
+        if ($this->confirm('Create the migration '."?")) {
226 226
 
227 227
             foreach ($tables as $key => $tableName) {
228 228
 
229
-                $this->class = 'create_table_' . $tableName;
229
+                $this->class = 'create_table_'.$tableName;
230 230
 
231 231
                 try {
232 232
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
                 $this->table = $this->getTableName($table);
252 252
 
253 253
                 foreach ($table->columns as $col) {
254
-                    $up .= "\t\t\t" . '\'' . $col->name . '\'=>"' . $this->getColType($col) . '",' . "\n";
254
+                    $up .= "\t\t\t".'\''.$col->name.'\'=>"'.$this->getColType($col).'",'."\n";
255 255
                     if ($col->isPrimaryKey) {
256 256
                         // Add column to composite primary key array
257 257
                         $compositePrimaryKeyCols[] = $col->name;
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 
261 261
                 $ukeys = $this->db->schema->findUniqueIndexes($table);
262 262
                 if (!empty($ukeys)) {
263
-                    $indexArr =[];
263
+                    $indexArr = [];
264 264
                     foreach ($ukeys as $key => $value) {
265 265
                         $indexKey = $key;
266 266
                         foreach ($value as $id => $field) {
@@ -268,15 +268,15 @@  discard block
 block discarded – undo
268 268
                         }
269 269
                     }
270 270
                     $indexStr = implode(',', $indexArr);
271
-                    $up .= "\t\t" . '$this->createIndex(\'idx_' . $indexKey . "', '" . $this->getTableName($table) . "', '$indexStr', TRUE);\n";
271
+                    $up .= "\t\t".'$this->createIndex(\'idx_'.$indexKey."', '".$this->getTableName($table)."', '$indexStr', TRUE);\n";
272 272
 
273 273
                 }
274 274
 
275 275
                 if (!empty($table->foreignKeys)):
276 276
 
277 277
                     foreach ($table->foreignKeys as $fkName => $fk) {
278
-                        $addForeignKeys .= "\t\t" . '$this->addForeignKey("' . $fkName . '", "' . $table->name . '", "' . $fk['column'] . '","' . $fk['table'] . '","' . $fk['ref_column'] . '", "' . $fk['delete'] . '", "' . $fk['update'] . '");' . "\n";
279
-                        $dropForeignKeys .= '$this->dropForeignKey(' . "'$fkName', '$table->name');";
278
+                        $addForeignKeys .= "\t\t".'$this->addForeignKey("'.$fkName.'", "'.$table->name.'", "'.$fk['column'].'","'.$fk['table'].'","'.$fk['ref_column'].'", "'.$fk['delete'].'", "'.$fk['update'].'");'."\n";
279
+                        $dropForeignKeys .= '$this->dropForeignKey('."'$fkName', '$table->name');";
280 280
                     }
281 281
 
282 282
                 endif;
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 
286 286
                 $fields = $this->parseFields();
287 287
 
288
-                $this->prepareFile(['up' => '', 'down' => '', 'foreignKeys' => $table->foreignKeys, 'fields' => $fields]) . "\n\n";
288
+                $this->prepareFile(['up' => '', 'down' => '', 'foreignKeys' => $table->foreignKeys, 'fields' => $fields])."\n\n";
289 289
 
290 290
             }
291 291
 
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
     public function actionData(array $tables)
302 302
     {
303 303
 
304
-        if ($this->confirm('Create the migration ' . "?", true)) {
304
+        if ($this->confirm('Create the migration '."?", true)) {
305 305
             foreach ($tables as $key => $args) {
306 306
 
307 307
                 $table              = $args;
308
-                $this->class        = 'insert_data_into_' . $table;
308
+                $this->class        = 'insert_data_into_'.$table;
309 309
                 $this->table        = $table;
310 310
                 $this->templateFile = '@tmukherjee13/migration/views/dataTemplate.php';
311 311
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
                     $pcolumns = '';
335 335
                     foreach ($columns->columns as $column) {
336
-                        $pcolumns .= "'" . $column->name . "',";
336
+                        $pcolumns .= "'".$column->name."',";
337 337
                     }
338 338
                     foreach ($data as $row) {
339 339
                         array_push($prepared_data, $row);
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
     {
364 364
 
365 365
         $schema      = $args;
366
-        $this->class = 'dump_database_' . $schema;
366
+        $this->class = 'dump_database_'.$schema;
367 367
 
368 368
         // $tables = $this->db->schema->getTableNames($schema);
369 369
 
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
         $generateTables  = [];
379 379
 
380 380
         foreach ($tables as $table) {
381
-            if ($table->name === $this->db->tablePrefix . $this->migrationTable) {
381
+            if ($table->name === $this->db->tablePrefix.$this->migrationTable) {
382 382
                 continue;
383 383
             }
384 384
             $generateTables[] = $table->name;
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 
391 391
     public function getFileName()
392 392
     {
393
-        return 'm' . gmdate('ymd_His') . '_' . $this->class;
393
+        return 'm'.gmdate('ymd_His').'_'.$this->class;
394 394
     }
395 395
 
396 396
     public function setFileName()
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
     public function prepareFile($data)
402 402
     {
403 403
         if ($this->useDataMigrationFolder) {
404
-            FileHelper::createDirectory($this->migrationPath . DIRECTORY_SEPARATOR . $this->dataMigrationFolder);
404
+            FileHelper::createDirectory($this->migrationPath.DIRECTORY_SEPARATOR.$this->dataMigrationFolder);
405 405
         }
406
-        $file = $this->migrationPath . DIRECTORY_SEPARATOR . ($this->useDataMigrationFolder ? $this->dataMigrationFolder . DIRECTORY_SEPARATOR : null) . $this->getFileName() . '.php';
406
+        $file = $this->migrationPath.DIRECTORY_SEPARATOR.($this->useDataMigrationFolder ? $this->dataMigrationFolder.DIRECTORY_SEPARATOR : null).$this->getFileName().'.php';
407 407
         try {
408 408
 
409 409
             $data['table']     = $this->table;
Please login to merge, or discard this patch.
Braces   +21 added lines, -36 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@  discard block
 block discarded – undo
10 10
 use yii\helpers\Console;
11 11
 use yii\helpers\FileHelper;
12 12
 
13
-class MigrationController extends MigrateController
14
-{
13
+class MigrationController extends MigrateController {
15 14
     use \tmukherjee13\migration\console\components\Formatter;
16 15
 
17 16
     /**
@@ -70,16 +69,14 @@  discard block
 block discarded – undo
70 69
     /**
71 70
      * @inheritdoc
72 71
      */
73
-    public function options($actionID)
74
-    {
72
+    public function options($actionID) {
75 73
         return array_merge(parent::options($actionID), ['migrationTable', 'db']);
76 74
     }
77 75
 
78 76
     /**
79 77
      * @inheritdoc
80 78
      */
81
-    public function beforeAction($action)
82
-    {
79
+    public function beforeAction($action) {
83 80
 
84 81
         if (parent::beforeAction($action)) {
85 82
             if (is_string($this->db)) {
@@ -113,8 +110,7 @@  discard block
 block discarded – undo
113 110
      * Collects the foreign key column details for the given table.
114 111
      * @param TableSchema $table the table metadata
115 112
      */
116
-    protected function findConstraints($table)
117
-    {
113
+    protected function findConstraints($table) {
118 114
         $sql = <<<SQL
119 115
             SELECT
120 116
                 kcu.constraint_name,
@@ -182,20 +178,19 @@  discard block
 block discarded – undo
182 178
      * @param TableSchema $table the table metadata
183 179
      * @return string $sql the result of 'SHOW CREATE TABLE'
184 180
      */
185
-    protected function getCreateTableSql($table)
186
-    {
181
+    protected function getCreateTableSql($table) {
187 182
         $row = $this->db->createCommand('SHOW CREATE TABLE ' . $this->quoteTableName($table->fullName))->queryOne();
188 183
         if (isset($row['Create Table'])) {
189 184
             $sql = $row['Create Table'];
190
-        } else {
185
+        }
186
+        else {
191 187
             $row = array_values($row);
192 188
             $sql = $row[1];
193 189
         }
194 190
         return $sql;
195 191
     }
196 192
 
197
-    public function quoteTableName($name)
198
-    {
193
+    public function quoteTableName($name) {
199 194
         return strpos($name, '`') !== false ? $name : "`$name`";
200 195
     }
201 196
 
@@ -205,8 +200,7 @@  discard block
 block discarded – undo
205 200
      * @param int $limit
206 201
      * @return int
207 202
      */
208
-    public function actionUpData($limit = 0)
209
-    {
203
+    public function actionUpData($limit = 0) {
210 204
         $this->migrationPath .= DIRECTORY_SEPARATOR . $this->dataMigrationFolder;
211 205
         return parent::actionUp($limit);
212 206
     }
@@ -219,8 +213,7 @@  discard block
 block discarded – undo
219 213
      * @author Tarun Mukherjee (https://github.com/tmukherjee13)
220 214
      */
221 215
 
222
-    public function actionTable(array $tables)
223
-    {
216
+    public function actionTable(array $tables) {
224 217
 
225 218
         if ($this->confirm('Create the migration ' . "?")) {
226 219
 
@@ -298,8 +291,7 @@  discard block
 block discarded – undo
298 291
      * @param array $tables the list of tables
299 292
      * @return integer|null
300 293
      */
301
-    public function actionData(array $tables)
302
-    {
294
+    public function actionData(array $tables) {
303 295
 
304 296
         if ($this->confirm('Create the migration ' . "?", true)) {
305 297
             foreach ($tables as $key => $args) {
@@ -341,7 +333,8 @@  discard block
 block discarded – undo
341 333
 
342 334
                     if (empty($prepared_data)) {
343 335
                         $this->stdout("\nTable '{$table->name}' doesn't contain any data.\n\n", Console::FG_RED);
344
-                    } else {
336
+                    }
337
+                    else {
345 338
                         $pcolumns = $this->prepareColumns($pcolumns);
346 339
                         $prows    = $this->prepareData($prepared_data);
347 340
 
@@ -359,8 +352,7 @@  discard block
 block discarded – undo
359 352
      * @param string $args the schema name
360 353
      * @return integer
361 354
      */
362
-    public function actionSchema($args)
363
-    {
355
+    public function actionSchema($args) {
364 356
 
365 357
         $schema      = $args;
366 358
         $this->class = 'dump_database_' . $schema;
@@ -388,18 +380,15 @@  discard block
 block discarded – undo
388 380
 
389 381
     }
390 382
 
391
-    public function getFileName()
392
-    {
383
+    public function getFileName() {
393 384
         return 'm' . gmdate('ymd_His') . '_' . $this->class;
394 385
     }
395 386
 
396
-    public function setFileName()
397
-    {
387
+    public function setFileName() {
398 388
         $this->fileName = $this->getFileName();
399 389
     }
400 390
 
401
-    public function prepareFile($data)
402
-    {
391
+    public function prepareFile($data) {
403 392
         if ($this->useDataMigrationFolder) {
404 393
             FileHelper::createDirectory($this->migrationPath . DIRECTORY_SEPARATOR . $this->dataMigrationFolder);
405 394
         }
@@ -422,8 +411,7 @@  discard block
 block discarded – undo
422 411
     /**
423 412
      * @inheritdoc
424 413
      */
425
-    protected function getMigrationHistory($limit)
426
-    {
414
+    protected function getMigrationHistory($limit) {
427 415
         if ($this->db->schema->getTableSchema($this->migrationTable, true) === null) {
428 416
             $this->createMigrationHistoryTable();
429 417
         }
@@ -443,8 +431,7 @@  discard block
 block discarded – undo
443 431
     /**
444 432
      * @inheritdoc
445 433
      */
446
-    protected function addMigrationHistory($version)
447
-    {
434
+    protected function addMigrationHistory($version) {
448 435
         $command = $this->db->createCommand();
449 436
         $command->insert($this->migrationTable, [
450 437
             'version'    => $version,
@@ -455,8 +442,7 @@  discard block
 block discarded – undo
455 442
     /**
456 443
      * @inheritdoc
457 444
      */
458
-    protected function removeMigrationHistory($version)
459
-    {
445
+    protected function removeMigrationHistory($version) {
460 446
         $command = $this->db->createCommand();
461 447
         $command->delete($this->migrationTable, [
462 448
             'version' => $version,
@@ -466,8 +452,7 @@  discard block
 block discarded – undo
466 452
     /**
467 453
      * @inheritdoc
468 454
      */
469
-    protected function parseFields()
470
-    {
455
+    protected function parseFields() {
471 456
         $fields = [];
472 457
 
473 458
         foreach ($this->fields as $column => $schema) {
Please login to merge, or discard this patch.