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
02:12
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;
@@ -154,19 +149,22 @@  discard block
 block discarded – undo
154 149
      * @author Tarun Mukherjee (https://github.com/tmukherjee13)
155 150
      */
156 151
 
157
-    public function formatCol($col)
158
-    {
152
+    public function formatCol($col) {
159 153
         $decorator = [];
160 154
         if ($col->isPrimaryKey && $col->autoIncrement) {
161 155
             $decorator[] = 'primaryKey';
162
-        } elseif (in_array($col->type, self::$colTypes)) {
156
+        }
157
+        elseif (in_array($col->type, self::$colTypes)) {
163 158
             $decorator[] = "{$col->phpType}";
164
-        } elseif ($col->type == 'decimal') {
159
+        }
160
+        elseif ($col->type == 'decimal') {
165 161
             $decorator[] = "{$col->dbType}";
166
-        } else {
162
+        }
163
+        else {
167 164
             if (!empty($col->size) && $col->size == 1 && $col->type != 'char') {
168 165
                 $column = "boolean";
169
-            } else {
166
+            }
167
+            else {
170 168
                 $column = "{$col->type}";
171 169
                 if (!empty($col->size)) {
172 170
                     $column .= "({$col->size})";
Please login to merge, or discard this patch.
console/controllers/MigrationController.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
                 throw new Exception("The 'db' option must refer to the application component ID of a DB connection.");
79 79
             }
80 80
 
81
-            $path = (string)Yii::getAlias($this->migrationPath);
81
+            $path = (string) Yii::getAlias($this->migrationPath);
82 82
 
83 83
 
84 84
             if (!is_dir($path)) {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      */
174 174
     protected function getCreateTableSql($table)
175 175
     {
176
-        $row = $this->db->createCommand('SHOW CREATE TABLE ' . $this->quoteTableName($table->fullName))->queryOne();
176
+        $row = $this->db->createCommand('SHOW CREATE TABLE '.$this->quoteTableName($table->fullName))->queryOne();
177 177
         if (isset($row['Create Table'])) {
178 178
             $sql = $row['Create Table'];
179 179
         } else {
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
     public function actionTable(array $tables)
200 200
     {
201 201
 
202
-        if ($this->confirm('Create the migration ' . "?")) {
202
+        if ($this->confirm('Create the migration '."?")) {
203 203
 
204 204
             foreach ($tables as $key => $tableName) {
205 205
 
206
-                $this->class = 'create_table_' . $tableName;
206
+                $this->class = 'create_table_'.$tableName;
207 207
 
208 208
                 try {
209 209
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                 $this->table = $this->getTableName($table);
229 229
 
230 230
                 foreach ($table->columns as $col) {
231
-                    $up .= "\t\t\t" . '\'' . $col->name . '\'=>"' . $this->getColType($col) . '",' . "\n";
231
+                    $up .= "\t\t\t".'\''.$col->name.'\'=>"'.$this->getColType($col).'",'."\n";
232 232
                     if ($col->isPrimaryKey) {
233 233
                         // Add column to composite primary key array
234 234
                         $compositePrimaryKeyCols[] = $col->name;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
                 $ukeys = $this->db->schema->findUniqueIndexes($table);
239 239
                 if (!empty($ukeys)) {
240
-                    $indexArr =[];
240
+                    $indexArr = [];
241 241
                     foreach ($ukeys as $key => $value) {
242 242
                         $indexKey = $key;
243 243
                         foreach ($value as $id => $field) {
@@ -245,15 +245,15 @@  discard block
 block discarded – undo
245 245
                         }
246 246
                     }
247 247
                     $indexStr = implode(',', $indexArr);
248
-                    $up .= "\t\t" . '$this->createIndex(\'idx_' . $indexKey . "', '" . $this->getTableName($table) . "', '$indexStr', TRUE);\n";
248
+                    $up .= "\t\t".'$this->createIndex(\'idx_'.$indexKey."', '".$this->getTableName($table)."', '$indexStr', TRUE);\n";
249 249
 
250 250
                 }
251 251
 
252 252
                 if (!empty($table->foreignKeys)):
253 253
 
254 254
                     foreach ($table->foreignKeys as $fkName => $fk) {
255
-                        $addForeignKeys .= "\t\t" . '$this->addForeignKey("' . $fkName . '", "' . $table->name . '", "' . $fk['column'] . '","' . $fk['table'] . '","' . $fk['ref_column'] . '", "' . $fk['delete'] . '", "' . $fk['update'] . '");' . "\n";
256
-                        $dropForeignKeys .= '$this->dropForeignKey(' . "'$fkName', '$table->name');";
255
+                        $addForeignKeys .= "\t\t".'$this->addForeignKey("'.$fkName.'", "'.$table->name.'", "'.$fk['column'].'","'.$fk['table'].'","'.$fk['ref_column'].'", "'.$fk['delete'].'", "'.$fk['update'].'");'."\n";
256
+                        $dropForeignKeys .= '$this->dropForeignKey('."'$fkName', '$table->name');";
257 257
                     }
258 258
 
259 259
                 endif;
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 
263 263
                 $fields = $this->parseFields();
264 264
 
265
-                $this->prepareFile(['up' => '', 'down' => '', 'foreignKeys' => $table->foreignKeys, 'fields' => $fields]) . "\n\n";
265
+                $this->prepareFile(['up' => '', 'down' => '', 'foreignKeys' => $table->foreignKeys, 'fields' => $fields])."\n\n";
266 266
 
267 267
             }
268 268
 
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
     public function actionData(array $tables)
279 279
     {
280 280
 
281
-        if ($this->confirm('Create the migration ' . "?", true)) {
281
+        if ($this->confirm('Create the migration '."?", true)) {
282 282
             foreach ($tables as $key => $args) {
283 283
 
284 284
                 $table              = $args;
285
-                $this->class        = 'insert_data_into_' . $table;
285
+                $this->class        = 'insert_data_into_'.$table;
286 286
                 $this->table        = $table;
287 287
                 $this->templateFile = '@tmukherjee13/migration/views/dataTemplate.php';
288 288
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
                     $pcolumns = '';
312 312
                     foreach ($columns->columns as $column) {
313
-                        $pcolumns .= "'" . $column->name . "',";
313
+                        $pcolumns .= "'".$column->name."',";
314 314
                     }
315 315
                     foreach ($data as $row) {
316 316
                         array_push($prepared_data, $row);
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
     {
343 343
 
344 344
         $schema      = $args;
345
-        $this->class = 'dump_database_' . $schema;
345
+        $this->class = 'dump_database_'.$schema;
346 346
 
347 347
         // $tables = $this->db->schema->getTableNames($schema);
348 348
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
         $generateTables  = [];
358 358
 
359 359
         foreach ($tables as $table) {
360
-            if ($table->name === $this->db->tablePrefix . $this->migrationTable) {
360
+            if ($table->name === $this->db->tablePrefix.$this->migrationTable) {
361 361
                 continue;
362 362
             }
363 363
             $generateTables[] = $table->name;
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
     public function getFileName()
371 371
     {
372
-        return 'm' . gmdate('ymd_His') . '_' . $this->class;
372
+        return 'm'.gmdate('ymd_His').'_'.$this->class;
373 373
     }
374 374
 
375 375
     public function setFileName()
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 
380 380
     public function prepareFile($data)
381 381
     {
382
-        $file = $this->migrationPath . DIRECTORY_SEPARATOR . $this->getFileName() . '.php';
382
+        $file = $this->migrationPath.DIRECTORY_SEPARATOR.$this->getFileName().'.php';
383 383
         try {
384 384
 
385 385
             $data['table']     = $this->table;
Please login to merge, or discard this patch.
Braces   +20 added lines, -34 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
     /**
@@ -60,16 +59,14 @@  discard block
 block discarded – undo
60 59
     /**
61 60
      * @inheritdoc
62 61
      */
63
-    public function options($actionID)
64
-    {
62
+    public function options($actionID) {
65 63
         return array_merge(parent::options($actionID), ['migrationTable', 'db']);
66 64
     }
67 65
 
68 66
     /**
69 67
      * @inheritdoc
70 68
      */
71
-    public function beforeAction($action)
72
-    {
69
+    public function beforeAction($action) {
73 70
 
74 71
         if (parent::beforeAction($action)) {
75 72
             if (is_string($this->db)) {
@@ -103,8 +100,7 @@  discard block
 block discarded – undo
103 100
      * Collects the foreign key column details for the given table.
104 101
      * @param TableSchema $table the table metadata
105 102
      */
106
-    protected function findConstraints($table)
107
-    {
103
+    protected function findConstraints($table) {
108 104
         $sql = <<<SQL
109 105
             SELECT
110 106
                 kcu.constraint_name,
@@ -172,20 +168,19 @@  discard block
 block discarded – undo
172 168
      * @param TableSchema $table the table metadata
173 169
      * @return string $sql the result of 'SHOW CREATE TABLE'
174 170
      */
175
-    protected function getCreateTableSql($table)
176
-    {
171
+    protected function getCreateTableSql($table) {
177 172
         $row = $this->db->createCommand('SHOW CREATE TABLE ' . $this->quoteTableName($table->fullName))->queryOne();
178 173
         if (isset($row['Create Table'])) {
179 174
             $sql = $row['Create Table'];
180
-        } else {
175
+        }
176
+        else {
181 177
             $row = array_values($row);
182 178
             $sql = $row[1];
183 179
         }
184 180
         return $sql;
185 181
     }
186 182
 
187
-    public function quoteTableName($name)
188
-    {
183
+    public function quoteTableName($name) {
189 184
         return strpos($name, '`') !== false ? $name : "`$name`";
190 185
     }
191 186
 
@@ -197,8 +192,7 @@  discard block
 block discarded – undo
197 192
      * @author Tarun Mukherjee (https://github.com/tmukherjee13)
198 193
      */
199 194
 
200
-    public function actionTable(array $tables)
201
-    {
195
+    public function actionTable(array $tables) {
202 196
 
203 197
         if ($this->confirm('Create the migration ' . "?")) {
204 198
 
@@ -276,8 +270,7 @@  discard block
 block discarded – undo
276 270
      * @param array $tables the list of tables
277 271
      * @return integer|null
278 272
      */
279
-    public function actionData(array $tables)
280
-    {
273
+    public function actionData(array $tables) {
281 274
 
282 275
         if ($this->confirm('Create the migration ' . "?", true)) {
283 276
             foreach ($tables as $key => $args) {
@@ -319,7 +312,8 @@  discard block
 block discarded – undo
319 312
 
320 313
                     if (empty($prepared_data)) {
321 314
                         $this->stdout("\nTable '{$table->name}' doesn't contain any data.\n\n", Console::FG_RED);
322
-                    } else {
315
+                    }
316
+                    else {
323 317
                         $pcolumns = $this->prepareColumns($pcolumns);
324 318
                         $prows    = $this->prepareData($prepared_data);
325 319
 
@@ -339,8 +333,7 @@  discard block
 block discarded – undo
339 333
      * @param string $args the schema name
340 334
      * @return integer
341 335
      */
342
-    public function actionSchema($args)
343
-    {
336
+    public function actionSchema($args) {
344 337
 
345 338
         $schema      = $args;
346 339
         $this->class = 'dump_database_' . $schema;
@@ -368,18 +361,15 @@  discard block
 block discarded – undo
368 361
 
369 362
     }
370 363
 
371
-    public function getFileName()
372
-    {
364
+    public function getFileName() {
373 365
         return 'm' . gmdate('ymd_His') . '_' . $this->class;
374 366
     }
375 367
 
376
-    public function setFileName()
377
-    {
368
+    public function setFileName() {
378 369
         $this->fileName = $this->getFileName();
379 370
     }
380 371
 
381
-    public function prepareFile($data)
382
-    {
372
+    public function prepareFile($data) {
383 373
         $file = $this->migrationPath . DIRECTORY_SEPARATOR . $this->getFileName() . '.php';
384 374
         try {
385 375
 
@@ -399,8 +389,7 @@  discard block
 block discarded – undo
399 389
     /**
400 390
      * @inheritdoc
401 391
      */
402
-    protected function getMigrationHistory($limit)
403
-    {
392
+    protected function getMigrationHistory($limit) {
404 393
         if ($this->db->schema->getTableSchema($this->migrationTable, true) === null) {
405 394
             $this->createMigrationHistoryTable();
406 395
         }
@@ -420,8 +409,7 @@  discard block
 block discarded – undo
420 409
     /**
421 410
      * @inheritdoc
422 411
      */
423
-    protected function addMigrationHistory($version)
424
-    {
412
+    protected function addMigrationHistory($version) {
425 413
         $command = $this->db->createCommand();
426 414
         $command->insert($this->migrationTable, [
427 415
             'version'    => $version,
@@ -432,8 +420,7 @@  discard block
 block discarded – undo
432 420
     /**
433 421
      * @inheritdoc
434 422
      */
435
-    protected function removeMigrationHistory($version)
436
-    {
423
+    protected function removeMigrationHistory($version) {
437 424
         $command = $this->db->createCommand();
438 425
         $command->delete($this->migrationTable, [
439 426
             'version' => $version,
@@ -443,8 +430,7 @@  discard block
 block discarded – undo
443 430
     /**
444 431
      * @inheritdoc
445 432
      */
446
-    protected function parseFields()
447
-    {
433
+    protected function parseFields() {
448 434
         $fields = [];
449 435
 
450 436
         foreach ($this->fields as $column => $schema) {
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.