Passed
Push — master ( 631a3d...011cd7 )
by Bruno
08:35
created
Modelarium/Laravel/Console/Commands/ModelariumFrontendCommand.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
         $writtenFiles = $this->writeFiles(
157 157
             $collection,
158 158
             $basepath,
159
-            function (GeneratedItem $i) use ($match) {
160
-                if ((bool)$this->option('overwrite') === true) {
159
+            function(GeneratedItem $i) use ($match) {
160
+                if ((bool) $this->option('overwrite') === true) {
161 161
                     return true;
162 162
                 }
163
-                if ((bool)$this->option('overwrite-graphql') === true) {
163
+                if ((bool) $this->option('overwrite-graphql') === true) {
164 164
                     if (
165 165
                         StringUtil::endsWith($i->filename, '.graphql')
166 166
                     ) {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
             // this runs all prettier commands in parallel.
190 190
             $run = array_reduce(
191 191
                 $writtenFiles,
192
-                function ($carry, $f) use ($command) {
192
+                function($carry, $f) use ($command) {
193 193
                     return $carry . '(' . $command . $f . ') & ';
194 194
                 }
195 195
             );
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
             // this runs all prettier commands in parallel.
209 209
             $run = array_reduce(
210 210
                 $writtenFiles,
211
-                function ($carry, $f) use ($command) {
211
+                function($carry, $f) use ($command) {
212 212
                     return $carry . '(' . $command . $f . ') & ';
213 213
                 }
214 214
             );
Please login to merge, or discard this patch.
Modelarium/Util.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
      */
48 48
     public static function scalars(array $datatypes, string $ns): array
49 49
     {
50
-        $graphql = [ "# File automatically generated by Modelarium\n" ];
50
+        $graphql = ["# File automatically generated by Modelarium\n"];
51 51
 
52 52
         foreach ($datatypes as $name) {
53 53
             $typeName = Str::studly($name);
Please login to merge, or discard this patch.
Modelarium/Laravel/Directives/CanDirective.php 2 patches
Switch Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -34,24 +34,24 @@
 block discarded – undo
34 34
 
35 35
         foreach ($directive->arguments as $arg) {
36 36
             switch ($arg->name->value) {
37
-                case 'ability':
38
-                    // @phpstan-ignore-next-line
39
-                    $ability = (string)$arg->value->value;
40
-                break;
41
-                case 'find':
42
-                    // @phpstan-ignore-next-line
43
-                    $find = $arg->value->value;
44
-                break;
45
-                case 'model':
46
-                    // @phpstan-ignore-next-line
47
-                    $modelName = $arg->value->value;
48
-                break;
49
-                case 'injectArgs':
50
-                    $injected = true;
51
-                break;
52
-                case 'args':
53
-                    $args = true;
54
-                break;
37
+            case 'ability':
38
+                // @phpstan-ignore-next-line
39
+                $ability = (string)$arg->value->value;
40
+            break;
41
+            case 'find':
42
+                // @phpstan-ignore-next-line
43
+                $find = $arg->value->value;
44
+            break;
45
+            case 'model':
46
+                // @phpstan-ignore-next-line
47
+                $modelName = $arg->value->value;
48
+            break;
49
+            case 'injectArgs':
50
+                $injected = true;
51
+            break;
52
+            case 'args':
53
+                $args = true;
54
+            break;
55 55
             }
56 56
         }
57 57
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
             switch ($arg->name->value) {
37 37
                 case 'ability':
38 38
                     // @phpstan-ignore-next-line
39
-                    $ability = (string)$arg->value->value;
39
+                    $ability = (string) $arg->value->value;
40 40
                 break;
41 41
                 case 'find':
42 42
                     // @phpstan-ignore-next-line
Please login to merge, or discard this patch.
Modelarium/Laravel/Directives/ModelExtendsDirective.php 2 patches
Switch Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@
 block discarded – undo
20 20
             $value = $arg->value->value;
21 21
 
22 22
             switch ($arg->name->value) {
23
-                case 'class':
24
-                    $generator->parentClassName = (string)$value;
25
-                break;
23
+            case 'class':
24
+                $generator->parentClassName = (string)$value;
25
+            break;
26 26
             }
27 27
         }
28 28
     }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 
22 22
             switch ($arg->name->value) {
23 23
                 case 'class':
24
-                    $generator->parentClassName = (string)$value;
24
+                    $generator->parentClassName = (string) $value;
25 25
                 break;
26 26
             }
27 27
         }
Please login to merge, or discard this patch.
Modelarium/Laravel/Processor.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * @param  string[]  $directiveNamespaces
79 79
      * @return array<string, string>
80 80
      */
81
-    public static function getDirectivesGraphql($directiveNamespaces = [ 'Modelarium\Laravel\Lighthouse\Directives' ]): array
81
+    public static function getDirectivesGraphql($directiveNamespaces = ['Modelarium\Laravel\Lighthouse\Directives']): array
82 82
     {
83 83
         $directives = [];
84 84
 
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
 
89 89
             foreach ($classesInNamespace as $class) {
90 90
                 $reflection = new \ReflectionClass($class);
91
-                if (! $reflection->isInstantiable()) {
91
+                if (!$reflection->isInstantiable()) {
92 92
                     continue;
93 93
                 }
94 94
 
95
-                if (! is_a($class, \Nuwave\Lighthouse\Schema\Directives\BaseDirective::class, true)) {
95
+                if (!is_a($class, \Nuwave\Lighthouse\Schema\Directives\BaseDirective::class, true)) {
96 96
                     continue;
97 97
                 }
98 98
                 
99
-                $name = \Nuwave\Lighthouse\Schema\DirectiveLocator::directiveName((string)$class);
99
+                $name = \Nuwave\Lighthouse\Schema\DirectiveLocator::directiveName((string) $class);
100 100
                 $directives[$name] = trim($class::definition());
101 101
             }
102 102
         }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      * @param  string[]  $directiveNamespaces
111 111
      * @return string
112 112
      */
113
-    public static function getDirectivesGraphqlString($directiveNamespaces = [ 'Modelarium\\Laravel\\Lighthouse\\Directives' ]): string
113
+    public static function getDirectivesGraphqlString($directiveNamespaces = ['Modelarium\\Laravel\\Lighthouse\\Directives']): string
114 114
     {
115 115
         return implode("\n\n", self::getDirectivesGraphql($directiveNamespaces));
116 116
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
                 if ($name === 'Query' || $name === 'Mutation' || $name === 'Subscription' || $name === 'Can') {
168 168
                     continue;
169 169
                 }
170
-                $g = $this->processType((string)$name, $object);
170
+                $g = $this->processType((string) $name, $object);
171 171
                 $this->collection = $this->collection->merge($g);
172 172
             }
173 173
         }
Please login to merge, or discard this patch.
Modelarium/Parser.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     {
179 179
         $originalTypeLoader = $this->schema->getConfig()->typeLoader;
180 180
 
181
-        $this->schema->getConfig()->typeLoader = function ($typeName) use ($originalTypeLoader) {
181
+        $this->schema->getConfig()->typeLoader = function($typeName) use ($originalTypeLoader) {
182 182
             $type = $originalTypeLoader($typeName);
183 183
             if ($type instanceof \GraphQL\Type\Definition\CustomScalarType) {
184 184
                 $scalarName = $type->name;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     {
194 194
         $this->ast = Visitor::visit($this->ast, [
195 195
             // load the scalar type classes
196
-            NodeKind::SCALAR_TYPE_DEFINITION => function ($node) {
196
+            NodeKind::SCALAR_TYPE_DEFINITION => function($node) {
197 197
                 $scalarName = $node->name->value;
198 198
 
199 199
                 // load classes
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
                             switch ($arg->name->value) {
208 208
                             case 'class':
209
-                                $className = (string)$value;
209
+                                $className = (string) $value;
210 210
                             break;
211 211
                             }
212 212
                         }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
             return [];
253 253
         }
254 254
         return array_map(
255
-            function ($i) use ($basedir) {
255
+            function($i) use ($basedir) {
256 256
                 $name = $i[1];
257 257
                 if (array_key_exists($name, $this->imports)) {
258 258
                     return $this->imports[$name];
Please login to merge, or discard this patch.
Modelarium/Laravel/Targets/MigrationGenerator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
                 'enum',
222 222
                 'App\\Datatypes',
223 223
                 'Tests\\Unit',
224
-                function (ClassType $enumClass) use ($enumValues) {
224
+                function(ClassType $enumClass) use ($enumValues) {
225 225
                     $enumClass->addConstant('CHOICES', $enumValues);
226 226
                     $enumClass->getMethod('__construct')->addBody('$this->choices = self::CHOICES;');
227 227
                 }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         }
271 271
 
272 272
         $options = []; // TODO: from directives
273
-        $codeFragment->appendBase('$table->'  . $ourType->getLaravelSQLType($fieldName, $options));
273
+        $codeFragment->appendBase('$table->' . $ourType->getLaravelSQLType($fieldName, $options));
274 274
     }
275 275
 
276 276
     /**
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
             $this->getBasePath(
409 409
                 'database/migrations/' .
410 410
                 $this->stamp .
411
-                str_pad((string)(static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
411
+                str_pad((string) (static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
412 412
                 '_' . $this->mode . '_' .
413 413
                 $relation .
414 414
                 '_table.php'
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
             $this->getBasePath(
451 451
                 'database/migrations/' .
452 452
                 $this->stamp .
453
-                str_pad((string)(static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
453
+                str_pad((string) (static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
454 454
                 '_' . $this->mode . '_' .
455 455
                 $type1 . '_' . $type2 .
456 456
                 '_table.php'
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
         return $this->getBasePath(
496 496
             'database/migrations/' .
497 497
             $this->stamp .
498
-            str_pad((string)(static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
498
+            str_pad((string) (static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
499 499
             '_' . $this->mode . '_' .
500 500
             $basename . '_' .
501 501
             str_replace('_', '', $this->stamp) . '_' .
Please login to merge, or discard this patch.
Modelarium/Frontend/FrontendGenerator.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
     public function buildTemplateParameters(): void
155 155
     {
156 156
         $this->titleFields = $this->fModel->filterField(
157
-            function (Field $field) {
157
+            function(Field $field) {
158 158
                 return $field->getRenderable('title', false);
159 159
             }
160 160
         );
161 161
         $this->cardFields = $this->fModel->filterField(
162
-            function (Field $field) {
162
+            function(Field $field) {
163 163
                 return $field->getRenderable('card', false);
164 164
             }
165 165
         );
166 166
         $this->tableFields = $this->fModel->filterField(
167
-            function (Field $field) {
167
+            function(Field $field) {
168 168
                 return $field->getRenderable('table', false);
169 169
             }
170 170
         );
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
             'Table',
221 221
             [
222 222
                 Table::ROW_NAMES => array_map(
223
-                    function (Field $field) {
223
+                    function(Field $field) {
224 224
                         return $field->getRenderable(Renderable::LABEL, $field->getName());
225 225
                     },
226 226
                     $this->tableFields
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             $t->appendContent('<slot name="extraHeaders" :props="$props"></slot>', true);
246 246
         }
247 247
         $titleFields = $this->fModel->filterField(
248
-            function (Field $field) {
248
+            function(Field $field) {
249 249
                 return $field->getRenderable('title', false);
250 250
             }
251 251
         );
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             'spinner' => $spinner,
273 273
             'routeBase' => $this->getRouteBase(),
274 274
             'tablelist' => $table->getRenderHTML(),
275
-            'tableItemFields' => array_keys(array_map(function (Field $f) {
275
+            'tableItemFields' => array_keys(array_map(function(Field $f) {
276 276
                 return $f->getName();
277 277
             }, $this->tableFields)),
278 278
             'typeTitle' => $this->fModel->getRenderable('name', $this->studlyName),
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
                     $filters[] = [
351 351
                         'name' => $arg->name,
352 352
                         'type' => $typename,
353
-                        'graphqlType' =>  $arg->name  . ': ' .
353
+                        'graphqlType' =>  $arg->name . ': ' .
354 354
                             ($isArray ? '[' : '') .
355 355
                             $typename .
356 356
                             $isInternalRequiredString . // TODO: phpstan complains, issue with graphqlphp ($isInternalRequired ? '!' : '') .
357 357
                             ($isArray ? ']' : '') .
358 358
                             ($isRequired ? '!' : ''),
359
-                        'required' => (bool)$isRequired,
359
+                        'required' => (bool) $isRequired,
360 360
                         'requiredJSBoolean' => $isRequired ? 'true' : 'false'
361 361
                     ];
362 362
                 }
@@ -372,13 +372,13 @@  discard block
 block discarded – undo
372 372
          * card
373 373
          */
374 374
         $cardFieldNames = array_map(
375
-            function (Field $field) {
375
+            function(Field $field) {
376 376
                 return $field->getName();
377 377
             },
378 378
             $this->cardFields
379 379
         );
380 380
         $graphqlQuery = $this->fModel->mapFields(
381
-            function (Field $f) use ($cardFieldNames) {
381
+            function(Field $f) use ($cardFieldNames) {
382 382
                 if (in_array($f->getName(), $cardFieldNames)) {
383 383
                     // TODO: filter subfields in relationships
384 384
                     return $f->toGraphqlQuery();
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
             $filtersQuery = ', ' . join(
395 395
                 ', ',
396 396
                 array_map(
397
-                    function ($item) {
397
+                    function($item) {
398 398
                         // TODO: still buggy, misses the internal ! in [Xyz!]!
399 399
                         return '$' . $item['graphqlType'];
400 400
                     },
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
             $filtersParams = ', ' . join(
405 405
                 ', ',
406 406
                 array_map(
407
-                    function ($item) {
407
+                    function($item) {
408 408
                         return $item['name'] . ': $' . $item['name'];
409 409
                     },
410 410
                     $filters
@@ -443,14 +443,14 @@  discard block
 block discarded – undo
443 443
          * table
444 444
          */
445 445
         $tableFieldNames = array_map(
446
-            function (Field $field) {
446
+            function(Field $field) {
447 447
                 return $field->getName();
448 448
             },
449 449
             $this->tableFields
450 450
         );
451 451
 
452 452
         $graphqlQuery = $this->fModel->mapFields(
453
-            function (Field $f) use ($tableFieldNames) {
453
+            function(Field $f) use ($tableFieldNames) {
454 454
                 if (in_array($f->getName(), $tableFieldNames)) {
455 455
                     // TODO: filter subfields in relationships
456 456
                     return $f->toGraphqlQuery();
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
          * item
491 491
          */
492 492
         $graphqlQuery = $this->fModel->mapFields(
493
-            function (Field $f) {
493
+            function(Field $f) {
494 494
                 return \Modelarium\Frontend\Util::fieldShow($f) ? $f->toGraphqlQuery() : null;
495 495
             }
496 496
         );
Please login to merge, or discard this patch.
Modelarium/Frontend/FrontendVueGenerator.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                 Button::TYPE => ($hasVueRouter ? 'router-link' : 'a'),
137 137
                 Button::ATTRIBUTES => [
138 138
                     $targetAttribute => "/{$routeBase}/edit",
139
-                ] + ($hasCan ? [ "v-if" => 'can(\'create\')' ]: []),
139
+                ] + ($hasCan ? ["v-if" => 'can(\'create\')'] : []),
140 140
             ]
141 141
         )->setContent(
142 142
             '<i class="fa fa-plus"></i> Add new',
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
                 Button::TYPE => ($hasVueRouter ? 'router-link' : 'a'),
151 151
                 Button::ATTRIBUTES => [
152 152
                     $targetAttribute => "'/{$routeBase}/' + model.{$keyAttribute} + '/edit'",
153
-                ] + ($hasCan ? [ "v-if" => 'can(\'edit\')' ]: []),
153
+                ] + ($hasCan ? ["v-if" => 'can(\'edit\')'] : []),
154 154
             ]
155 155
         )->setContent(
156 156
             '<i class="fa fa-pencil"></i> Edit',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
                 Button::ATTRIBUTES => [
167 167
                     'href' => '#',
168 168
                     '@click.prevent' => 'remove',
169
-                ] + ($hasCan ? [ "v-if" => 'can(\'delete\')' ]: []),
169
+                ] + ($hasCan ? ["v-if" => 'can(\'delete\')'] : []),
170 170
             ]
171 171
         )->setContent(
172 172
             '<i class="fa fa-trash"></i> Delete',
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         $this->generator->templateParameters['options'] = $this->getOptions()->getSection('vue');
187 187
 
188 188
         $this->generator->templateParameters['tableItemFields'] =
189
-            array_values(array_map(function (Field $f) {
189
+            array_values(array_map(function(Field $f) {
190 190
                 if ($f->getDatatype()->getBasetype() === 'relationship') {
191 191
                     $name = $f->getName();
192 192
                     return "<{$name}-link v-bind=\"{$name}\"></{$name}-link>";
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
                 'required' => true
282 282
             ]
283 283
         ];
284
-        $cardFieldNames = array_map(function (Field $f) {
284
+        $cardFieldNames = array_map(function(Field $f) {
285 285
             return $f->getName();
286 286
         }, $this->generator->getCardFields());
287 287
         $vueCode->setExtraProps($extraprops);
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         $vueCode = $vue->getVueCode();
308 308
         // set basic data for vue
309 309
         $vueCode->setExtraProps([]);
310
-        $cardFieldNames = array_map(function (Field $f) {
310
+        $cardFieldNames = array_map(function(Field $f) {
311 311
             return $f->getName();
312 312
         }, $this->generator->getCardFields());
313 313
         foreach ($this->generator->getCardFields() as $f) {
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     public function vueTableItem(FrameworkVue $vue): void
341 341
     {
342 342
         $vueCode = $vue->getVueCode();
343
-        $tableFieldNames = array_map(function (Field $f) {
343
+        $tableFieldNames = array_map(function(Field $f) {
344 344
             return $f->getName();
345 345
         }, $this->generator->getTableFields());
346 346
         $vueCode->setExtraProps([]);
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
             $vue,
375 375
             'Form',
376 376
             'editable',
377
-            function (Field $f) {
377
+            function(Field $f) {
378 378
                 if (!$f->getExtradata('modelFillable')) {
379 379
                     return false;
380 380
                 }
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 
400 400
         if ($mode == 'editable') {
401 401
             $vue->setEditableTemplate(
402
-                function (FrameworkVue $vue, array $data, Model $m) use ($stub) {
402
+                function(FrameworkVue $vue, array $data, Model $m) use ($stub) {
403 403
                     return $this->generator->templateCallback($stub, $vue, $data, $m);
404 404
                 }
405 405
             );
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
             );
414 414
         } else {
415 415
             $vue->setViewableTemplate(
416
-                function (FrameworkVue $vue, array $data, Model $m) use ($stub) {
416
+                function(FrameworkVue $vue, array $data, Model $m) use ($stub) {
417 417
                     return $this->generator->templateCallback($stub, $vue, $data, $m);
418 418
                 }
419 419
             );
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
         $path = $this->generator->getModel()->getName() . '/index.js';
436 436
         $name = $this->generator->getStudlyName();
437 437
 
438
-        $contents = function ($basepath, $element) use ($name) {
438
+        $contents = function($basepath, $element) use ($name) {
439 439
             $dir = $basepath . '/' . $name;
440 440
             $import = [];
441 441
             $export = [];
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
         $path = $this->generator->getModel()->getName() . '/index.dynamic.js';
466 466
         $name = $this->generator->getStudlyName();
467 467
 
468
-        $contents = function ($basepath, $element) use ($name) {
468
+        $contents = function($basepath, $element) use ($name) {
469 469
             $dir = $basepath . '/' . $name;
470 470
             $import = [];
471 471
             $export = [];
Please login to merge, or discard this patch.