Completed
Pull Request — master (#1113)
by Martin
02:45
created
core/helpers/ArrayHelper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
         foreach ($array as $k => $v) {
51 51
             if (is_numeric($v)) {
52 52
                 if (is_float($v)) {
53
-                    $return[$k] = (float)$v;
53
+                    $return[$k] = (float) $v;
54 54
                 } else {
55
-                    $return[$k] = (int)$v;
55
+                    $return[$k] = (int) $v;
56 56
                 }
57 57
             } elseif (is_array($v)) {
58 58
                 $return[$k] = self::typeCast($v);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     public static function search($array, $searchText, $sensitive = false)
93 93
     {
94 94
         $function = ($sensitive) ? 'strpos' : 'stripos';
95
-        return array_filter($array, function ($item) use ($searchText, $function) {
95
+        return array_filter($array, function($item) use ($searchText, $function) {
96 96
             $response = false;
97 97
             foreach ($item as $key => $value) {
98 98
                 if ($response) {
Please login to merge, or discard this patch.
core/console/commands/BaseCrudController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
         }
75 75
         $rules = [];
76 76
         foreach ($types as $type => $columns) {
77
-            $rules[] = "[['" . implode("', '", $columns) . "'], '$type']";
77
+            $rules[] = "[['".implode("', '", $columns)."'], '$type']";
78 78
         }
79 79
         foreach ($lengths as $length => $columns) {
80
-            $rules[] = "[['" . implode("', '", $columns) . "'], 'string', 'max' => $length]";
80
+            $rules[] = "[['".implode("', '", $columns)."'], 'string', 'max' => $length]";
81 81
         }
82 82
         $db = $this->getDbConnection();
83 83
         // Unique indexes rules
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
                 if (!$this->isColumnAutoIncremental($table, $uniqueColumns)) {
89 89
                     $attributesCount = count($uniqueColumns);
90 90
                     if ($attributesCount === 1) {
91
-                        $rules[] = "[['" . $uniqueColumns[0] . "'], 'unique']";
91
+                        $rules[] = "[['".$uniqueColumns[0]."'], 'unique']";
92 92
                     } elseif ($attributesCount > 1) {
93 93
                         $labels = array_intersect_key($this->generateLabels($table), array_flip($uniqueColumns));
94 94
                         $lastLabel = array_pop($labels);
95 95
                         $columnsList = implode("', '", $uniqueColumns);
96
-                        $rules[] = "[['$columnsList'], 'unique', 'targetAttribute' => ['$columnsList'], 'message' => 'The combination of " . implode(', ', $labels) . " and $lastLabel has already been taken.']";
96
+                        $rules[] = "[['$columnsList'], 'unique', 'targetAttribute' => ['$columnsList'], 'message' => 'The combination of ".implode(', ', $labels)." and $lastLabel has already been taken.']";
97 97
                     }
98 98
                 }
99 99
             }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         $fullTableName = $tableName;
137 137
         if (($pos = strrpos($tableName, '.')) !== false) {
138 138
             if (($useSchemaName === null && $this->useSchemaName) || $useSchemaName) {
139
-                $schemaName = substr($tableName, 0, $pos) . '_';
139
+                $schemaName = substr($tableName, 0, $pos).'_';
140 140
             }
141 141
             $tableName = substr($tableName, $pos + 1);
142 142
         }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
             if (($pos = strrpos($pattern, '.')) !== false) {
150 150
                 $pattern = substr($pattern, $pos + 1);
151 151
             }
152
-            $patterns[] = '/^' . str_replace('*', '(\w+)', $pattern) . '$/';
152
+            $patterns[] = '/^'.str_replace('*', '(\w+)', $pattern).'$/';
153 153
         }
154 154
         $className = $tableName;
155 155
         foreach ($patterns as $pattern) {
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
             } else {
194 194
                 $label = Inflector::camel2words($column->name);
195 195
                 if (!empty($label) && substr_compare($label, ' id', -3, 3, true) === 0) {
196
-                    $label = substr($label, 0, -3) . ' ID';
196
+                    $label = substr($label, 0, -3).' ID';
197 197
                 }
198 198
                 $labels[$column->name] = $label;
199 199
             }
Please login to merge, or discard this patch.
core/console/commands/views/block/create_block.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,8 +88,8 @@
 block discarded – undo
88 88
     {
89 89
         return [
90 90
 <?php foreach ($extras as $extra):?>
91
-            <?= $extra;?>
92
-<?php endforeach;?>
91
+            <?= $extra; ?>
92
+<?php endforeach; ?>
93 93
 
94 94
         ];
95 95
     }
Please login to merge, or discard this patch.
core/console/commands/CrudController.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -279,7 +279,7 @@
 block discarded – undo
279 279
                 $this->getModelNameCamlized(),
280 280
                 $this->apiEndpoint,
281 281
                 $this->getDbTableShema()
282
-             ),
282
+                ),
283 283
         ];
284 284
         
285 285
         foreach ($files as $file) {
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
     /**
46 46
      * Get the $moduleName without admin suffix (if any).
47 47
      *
48
-     * @return mixed Return the module name without admin suffix.
48
+     * @return string Return the module name without admin suffix.
49 49
      */
50 50
     public function getModuleNameWithoutAdminSuffix()
51 51
     {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,6 @@
 block discarded – undo
6 6
 use yii\helpers\Console;
7 7
 use yii\helpers\Inflector;
8 8
 use yii\db\TableSchema;
9
-use luya\Boot;
10 9
 use luya\helpers\FileHelper;
11 10
 
12 11
 /**
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public function getAbsoluteModelNamespace()
81 81
     {
82
-        return $this->getModelNamespace() . '\\models\\' . $this->getModelNameCamlized();
82
+        return $this->getModelNamespace().'\\models\\'.$this->getModelNameCamlized();
83 83
     }
84 84
     
85 85
     /**
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
                 $sqlTable = $this->prompt('Database Table name for the Model:', ['required' => true, 'default' => $this->getDatabaseNameSuggestion()]);
376 376
                 if ($sqlTable == '?') {
377 377
                     foreach ($this->getSqlTablesArray() as $table) {
378
-                        $this->outputInfo("- " . $table);
378
+                        $this->outputInfo("- ".$table);
379 379
                     }
380 380
                 }
381 381
                 if (isset($this->getSqlTablesArray()[$sqlTable])) {
@@ -398,26 +398,26 @@  discard block
 block discarded – undo
398 398
         // api content
399 399
 
400 400
         $files['api'] = [
401
-            'path' => $this->getBasePath() . DIRECTORY_SEPARATOR . 'apis',
402
-            'fileName' => $this->getModelNameCamlized() . 'Controller.php',
403
-            'content' => $this->generateApiContent($this->getNamespace() . '\\apis', $this->getModelNameCamlized() . 'Controller', $this->getAbsoluteModelNamespace()),
401
+            'path' => $this->getBasePath().DIRECTORY_SEPARATOR.'apis',
402
+            'fileName' => $this->getModelNameCamlized().'Controller.php',
403
+            'content' => $this->generateApiContent($this->getNamespace().'\\apis', $this->getModelNameCamlized().'Controller', $this->getAbsoluteModelNamespace()),
404 404
         ];
405 405
         
406 406
         // controller
407 407
 
408 408
         $files['controller'] = [
409
-            'path' =>  $this->getBasePath() . DIRECTORY_SEPARATOR . 'controllers',
410
-            'fileName' => $this->getModelNameCamlized() . 'Controller.php',
411
-            'content' => $this->generateControllerContent($this->getNamespace() . '\\controllers', $this->getModelNameCamlized() . 'Controller', $this->getAbsoluteModelNamespace()),
409
+            'path' =>  $this->getBasePath().DIRECTORY_SEPARATOR.'controllers',
410
+            'fileName' => $this->getModelNameCamlized().'Controller.php',
411
+            'content' => $this->generateControllerContent($this->getNamespace().'\\controllers', $this->getModelNameCamlized().'Controller', $this->getAbsoluteModelNamespace()),
412 412
         ];
413 413
         
414 414
         // model
415 415
 
416 416
         $files['model'] = [
417
-            'path' =>  $this->getModelBasePath() . DIRECTORY_SEPARATOR . 'models',
418
-            'fileName' => $this->getModelNameCamlized() . '.php',
417
+            'path' =>  $this->getModelBasePath().DIRECTORY_SEPARATOR.'models',
418
+            'fileName' => $this->getModelNameCamlized().'.php',
419 419
             'content' => $this->generateModelContent(
420
-                $this->getModelNamespace() . '\\models',
420
+                $this->getModelNamespace().'\\models',
421 421
                 $this->getModelNameCamlized(),
422 422
                 $this->apiEndpoint,
423 423
                 $this->getDbTableShema(),
@@ -427,19 +427,19 @@  discard block
 block discarded – undo
427 427
         
428 428
         foreach ($files as $file) {
429 429
             FileHelper::createDirectory($file['path']);
430
-            if (file_exists($file['path'] . DIRECTORY_SEPARATOR . $file['fileName'])) {
430
+            if (file_exists($file['path'].DIRECTORY_SEPARATOR.$file['fileName'])) {
431 431
                 if (!$this->confirm("The File '{$file['fileName']}' already exists, do you want to override the existing file?")) {
432 432
                     continue;
433 433
                 }
434 434
             }
435 435
             
436
-            if (FileHelper::writeFile($file['path'] . DIRECTORY_SEPARATOR . $file['fileName'], $file['content'])) {
436
+            if (FileHelper::writeFile($file['path'].DIRECTORY_SEPARATOR.$file['fileName'], $file['content'])) {
437 437
                 $this->outputSuccess("Wrote file '{$file['fileName']}'.");
438 438
             } else {
439 439
                 $this->outputError("Error while writing file '{$file['fileName']}'.");
440 440
             }
441 441
         }
442 442
         
443
-        return $this->outputSuccess($this->generateBuildSummery($this->apiEndpoint, $this->getNamespace() . '\\apis\\' . $this->getModelNameCamlized() . 'Controller', $this->getModelNameCamlized(), $this->getSummaryControllerRoute()));
443
+        return $this->outputSuccess($this->generateBuildSummery($this->apiEndpoint, $this->getNamespace().'\\apis\\'.$this->getModelNameCamlized().'Controller', $this->getModelNameCamlized(), $this->getSummaryControllerRoute()));
444 444
     }
445 445
 }
Please login to merge, or discard this patch.
core/console/commands/views/crud/create_controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,5 +19,5 @@
 block discarded – undo
19 19
     /**
20 20
      * @var string $modelClass The path to the model which is the provider for the rules and fields.
21 21
      */
22
-    public $modelClass = '<?= $modelClass;?>';
22
+    public $modelClass = '<?= $modelClass; ?>';
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
core/console/commands/views/crud/create_api.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,5 +19,5 @@
 block discarded – undo
19 19
     /**
20 20
      * @var string $modelClass The path to the model which is the provider for the rules and fields.
21 21
      */
22
-    public $modelClass = '<?= $modelClass;?>';
22
+    public $modelClass = '<?= $modelClass; ?>';
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
core/console/commands/views/crud/create_model.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 /**
11 11
  * NgRest Model created with LUYA Version <?php echo $luyaVersion; ?>.
12 12
  *
13
-<?php foreach ($properties as $name => $type): ?> * @property <?= $type; ?> $<?= $name . PHP_EOL; ?>
14
-<?php endforeach;?>
13
+<?php foreach ($properties as $name => $type): ?> * @property <?= $type; ?> $<?= $name.PHP_EOL; ?>
14
+<?php endforeach; ?>
15 15
  */
16 16
 class <?= $className; ?> extends NgRestModel
17 17
 {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public $i18n = ['<?= implode("', '", $textFields); ?>'];
53 53
 
54
-<?php endif;?>
54
+<?php endif; ?>
55 55
     /**
56 56
      * @inheritdoc
57 57
      */
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     {
87 87
         return [
88 88
         <?php foreach ($ngrestFieldConfig as $name => $type): ?>
89
-    '<?=$name; ?>' => '<?= $type;?>',
89
+    '<?=$name; ?>' => '<?= $type; ?>',
90 90
         <?php endforeach; ?>];
91 91
     }
92 92
     
Please login to merge, or discard this patch.
core/console/commands/BlockController.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -146,19 +146,19 @@  discard block
 block discarded – undo
146 146
     private function getExtraVarDef($type, $varName, $func)
147 147
     {
148 148
         $info = [
149
-            'image-upload' => function ($varName) use ($func) {
149
+            'image-upload' => function($varName) use ($func) {
150 150
                 return 'BlockHelper::imageUpload($this->'.$func.'(\''.$varName.'\'), false, true),';
151 151
             },
152
-            'image-array-upload' => function ($varName) use ($func) {
152
+            'image-array-upload' => function($varName) use ($func) {
153 153
                 return 'BlockHelper::imageArrayUpload($this->'.$func.'(\''.$varName.'\'), false, true),';
154 154
             },
155
-            'file-upload' => function ($varName) use ($func) {
155
+            'file-upload' => function($varName) use ($func) {
156 156
                 return 'BlockHelper::fileUpload($this->'.$func.'(\''.$varName.'\'), true),';
157 157
             },
158
-            'file-array-upload' => function ($varName) use ($func) {
158
+            'file-array-upload' => function($varName) use ($func) {
159 159
                 return 'BlockHelper::fileArrayUpload($this->'.$func.'(\''.$varName.'\'), true),';
160 160
             },
161
-            'cms-page' => function ($varName) use ($func) {
161
+            'cms-page' => function($varName) use ($func) {
162 162
                 return 'Yii::$app->menu->findOne([\'nav_id\' => $this->'.$func.'(\''.$varName.'\', 0)]),';
163 163
             },
164 164
         ];
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
             return 'app\\blocks';
247 247
         }
248 248
 
249
-        return Yii::$app->getModule($this->moduleName)->getNamespace()  . '\\blocks';
249
+        return Yii::$app->getModule($this->moduleName)->getNamespace().'\\blocks';
250 250
     }
251 251
 
252 252
     protected function getFileBasePath()
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
             }
344 344
         }
345 345
         
346
-        $folder = $this->getFileBasePath() . DIRECTORY_SEPARATOR . 'blocks';
347
-        $filePath = $folder . DIRECTORY_SEPARATOR . $this->blockName . '.php';
346
+        $folder = $this->getFileBasePath().DIRECTORY_SEPARATOR.'blocks';
347
+        $filePath = $folder.DIRECTORY_SEPARATOR.$this->blockName.'.php';
348 348
         
349 349
         sort($this->phpdoc);
350 350
         
@@ -368,14 +368,14 @@  discard block
 block discarded – undo
368 368
         if (FileHelper::createDirectory($folder) && FileHelper::writeFile($filePath, $content)) {
369 369
             
370 370
             // generate view file based on block object view context
371
-            $object = Yii::createObject(['class' => $this->getFileNamespace() . '\\' . $this->blockName]);
371
+            $object = Yii::createObject(['class' => $this->getFileNamespace().'\\'.$this->blockName]);
372 372
             $viewsFolder = Yii::getAlias($object->getViewPath());
373
-            $viewFilePath = $viewsFolder . DIRECTORY_SEPARATOR . $object->getViewFileName('php');
373
+            $viewFilePath = $viewsFolder.DIRECTORY_SEPARATOR.$object->getViewFileName('php');
374 374
             if (FileHelper::createDirectory($viewsFolder) && FileHelper::writeFile($viewFilePath, $this->generateViewFile($this->blockName))) {
375
-                $this->outputInfo('View file for the block has been created: ' . $viewFilePath);
375
+                $this->outputInfo('View file for the block has been created: '.$viewFilePath);
376 376
             }
377 377
             
378
-            return $this->outputSuccess("Block {$this->blockName} has been created: " . $filePath);
378
+            return $this->outputSuccess("Block {$this->blockName} has been created: ".$filePath);
379 379
         }
380 380
         
381 381
         return $this->outputError("Error while creating block '$filePath'");
Please login to merge, or discard this patch.
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -146,6 +146,11 @@  discard block
 block discarded – undo
146 146
         ];
147 147
     }
148 148
     
149
+    /**
150
+     * @param string $type
151
+     * @param string $varName
152
+     * @param string $func
153
+     */
149 154
     private function getExtraVarDef($type, $varName, $func)
150 155
     {
151 156
         $info = [
@@ -173,6 +178,9 @@  discard block
 block discarded – undo
173 178
         return false;
174 179
     }
175 180
 
181
+    /**
182
+     * @param string $type
183
+     */
176 184
     private function getVariableTypeOption($type)
177 185
     {
178 186
         $types = $this->getVariableTypesOptions();
@@ -180,11 +188,17 @@  discard block
 block discarded – undo
180 188
         return $types[$type];
181 189
     }
182 190
 
191
+    /**
192
+     * @param string $type
193
+     */
183 194
     private function hasVariableTypeOption($type)
184 195
     {
185 196
         return array_key_exists($type, $this->getVariableTypesOptions());
186 197
     }
187 198
 
199
+    /**
200
+     * @param string $prefix
201
+     */
188 202
     private function placeholderCreator($prefix)
189 203
     {
190 204
         $this->output(PHP_EOL.'-> Create new '.$prefix, Console::FG_YELLOW);
Please login to merge, or discard this patch.
core/web/Composition.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -397,7 +397,7 @@
 block discarded – undo
397 397
      * 
398 398
      * @see ArrayAccess::offsetGet()
399 399
      * @param string $offset The key to get from the array.
400
-     * @return mixed The value for the offset key from the array.
400
+     * @return string|boolean The value for the offset key from the array.
401 401
      */
402 402
     public function offsetGet($offset)
403 403
     {
Please login to merge, or discard this patch.