Passed
Push — master ( 2310af...cdf82f )
by Bruno
07:53
created
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/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/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
                 if (in_array($scalarName, ['BuilderValue', 'CanArgs', 'EnumValue', 'EqValue'])) {
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
                             switch ($arg->name->value) {
213 213
                             case 'class':
214
-                                $className = (string)$value;
214
+                                $className = (string) $value;
215 215
                             break;
216 216
                             }
217 217
                         }
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
             return [];
258 258
         }
259 259
         return array_map(
260
-            function ($i) use ($basedir) {
260
+            function($i) use ($basedir) {
261 261
                 $name = $i[1];
262 262
                 if (array_key_exists($name, $this->imports)) {
263 263
                     return $this->imports[$name];
Please login to merge, or discard this patch.
Modelarium/Laravel/Targets/MigrationGenerator.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                 'enum',
231 231
                 'App\\Datatypes',
232 232
                 'Tests\\Unit',
233
-                function (ClassType $enumClass) use ($enumValues) {
233
+                function(ClassType $enumClass) use ($enumValues) {
234 234
                     $enumClass->addConstant('CHOICES', $enumValues);
235 235
                     $enumClass->getMethod('__construct')->addBody('$this->choices = self::CHOICES;');
236 236
                 }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         }
280 280
 
281 281
         $options = []; // TODO: from directives
282
-        $codeFragment->appendBase('$table->'  . $ourType->getLaravelSQLType($fieldName, $options));
282
+        $codeFragment->appendBase('$table->' . $ourType->getLaravelSQLType($fieldName, $options));
283 283
     }
284 284
 
285 285
     /**
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
             $this->getBasePath(
418 418
                 'database/migrations/' .
419 419
                 $this->stamp .
420
-                str_pad((string)(static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
420
+                str_pad((string) (static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
421 421
                 '_' . $this->mode . '_' .
422 422
                 $relation .
423 423
                 '_table.php'
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
             $this->getBasePath(
460 460
                 'database/migrations/' .
461 461
                 $this->stamp .
462
-                str_pad((string)(static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
462
+                str_pad((string) (static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
463 463
                 '_' . $this->mode . '_' .
464 464
                 $type1 . '_' . $type2 .
465 465
                 '_table.php'
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
         return $this->getBasePath(
505 505
             'database/migrations/' .
506 506
             $this->stamp .
507
-            str_pad((string)(static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
507
+            str_pad((string) (static::$counter++), 3, "0", STR_PAD_LEFT) . // so we keep the same order of types in schema
508 508
             '_' . $this->mode . '_' .
509 509
             $basename . '_' .
510 510
             str_replace('_', '', $this->stamp) . '_' .
@@ -525,10 +525,10 @@  discard block
 block discarded – undo
525 525
             return true;
526 526
         }
527 527
         $tokens = token_get_all($this->lastMigrationCode);
528
-        for ($i=0,$z=count($tokens); $i<$z; $i++) {
528
+        for ($i = 0, $z = count($tokens); $i < $z; $i++) {
529 529
             if (is_array($tokens[$i]) && $tokens[$i] === T_FUNCTION
530
-                && is_array($tokens[$i+1]) && $tokens[$i+1][0] == T_WHITESPACE
531
-                && is_array($tokens[$i+2]) && $tokens[$i+2][1] == 'up'
530
+                && is_array($tokens[$i + 1]) && $tokens[$i + 1][0] == T_WHITESPACE
531
+                && is_array($tokens[$i + 2]) && $tokens[$i + 2][1] == 'up'
532 532
             ) {
533 533
                 $accumulator = [];
534 534
                 // collect tokens from function head through opening brace
Please login to merge, or discard this patch.
Modelarium/Laravel/ServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,13 +72,13 @@
 block discarded – undo
72 72
          */
73 73
         Event::listen(
74 74
             RegisterDirectiveNamespaces::class,
75
-            function (RegisterDirectiveNamespaces $registerDirectiveNamespaces): string {
75
+            function(RegisterDirectiveNamespaces $registerDirectiveNamespaces): string {
76 76
                 return 'Modelarium\\Laravel\\Lighthouse\\Directives';
77 77
             }
78 78
         );
79 79
         Event::listen(
80 80
             RegisterDirectiveNamespaces::class,
81
-            function (RegisterDirectiveNamespaces $registerDirectiveNamespaces): string {
81
+            function(RegisterDirectiveNamespaces $registerDirectiveNamespaces): string {
82 82
                 return 'App\\Datatypes\\Types';
83 83
             }
84 84
         );
Please login to merge, or discard this patch.
Modelarium/Frontend/FrontendVueGenerator.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 Button::TYPE => ($hasVueRouter ? 'router-link' : 'a'),
99 99
                 Button::ATTRIBUTES => [
100 100
                     $targetAttribute => "/{$routeBase}/edit",
101
-                ] + ($hasCan ? [ "v-if" => 'can(\'create\')' ]: []),
101
+                ] + ($hasCan ? ["v-if" => 'can(\'create\')'] : []),
102 102
             ]
103 103
         )->setContent(
104 104
             '<i class="fa fa-plus"></i> Add new',
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                 Button::TYPE => ($hasVueRouter ? 'router-link' : 'a'),
113 113
                 Button::ATTRIBUTES => [
114 114
                     $targetAttribute => "'/{$routeBase}/' + model.{$keyAttribute} + '/edit'",
115
-                ] + ($hasCan ? [ "v-if" => 'can(\'edit\')' ]: []),
115
+                ] + ($hasCan ? ["v-if" => 'can(\'edit\')'] : []),
116 116
             ]
117 117
         )->setContent(
118 118
             '<i class="fa fa-pencil"></i> Edit',
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                 Button::ATTRIBUTES => [
129 129
                     'href' => '#',
130 130
                     '@click.prevent' => 'remove',
131
-                ] + ($hasCan ? [ "v-if" => 'can(\'delete\')' ]: []),
131
+                ] + ($hasCan ? ["v-if" => 'can(\'delete\')'] : []),
132 132
             ]
133 133
         )->setContent(
134 134
             '<i class="fa fa-trash"></i> Delete',
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         $this->generator->templateParameters['options'] = $this->getOptions()->options;
149 149
 
150 150
         $this->generator->templateParameters['tableItemFields'] =
151
-            array_values(array_map(function (Field $f) {
151
+            array_values(array_map(function(Field $f) {
152 152
                 $required = $f->getValidator('required', false);
153 153
                 if ($f->getDatatype()->getBasetype() === 'relationship') {
154 154
                     $name = $f->getName();
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                 'required' => true
245 245
             ]
246 246
         ];
247
-        $cardFieldNames = array_map(function (Field $f) {
247
+        $cardFieldNames = array_map(function(Field $f) {
248 248
             return $f->getName();
249 249
         }, $this->generator->getCardFields());
250 250
         $vueCode->setExtraProps($extraprops);
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         $vueCode = $vue->getVueCode();
271 271
         // set basic data for vue
272 272
         $vueCode->setExtraProps([]);
273
-        $cardFieldNames = array_map(function (Field $f) {
273
+        $cardFieldNames = array_map(function(Field $f) {
274 274
             return $f->getName();
275 275
         }, $this->generator->getCardFields());
276 276
         foreach ($this->generator->getCardFields() as $f) {
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
     public function vueTableItem(FrameworkVue $vue): void
304 304
     {
305 305
         $vueCode = $vue->getVueCode();
306
-        $tableFieldNames = array_map(function (Field $f) {
306
+        $tableFieldNames = array_map(function(Field $f) {
307 307
             return $f->getName();
308 308
         }, $this->generator->getTableFields());
309 309
         $vueCode->setExtraProps([]);
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
         $vueCode->setExtraProps([]);
351 351
 
352 352
         $createGraphqlVariables = $this->generator->getModel()->mapFields(
353
-            function (Field $f) {
353
+            function(Field $f) {
354 354
                 if (!$f->getRenderable('form', true)) {
355 355
                     return null;
356 356
                 }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
             $vue,
372 372
             'Form',
373 373
             'editable',
374
-            function (Field $f) {
374
+            function(Field $f) {
375 375
                 if (!$f->getExtradata('modelFillable')) {
376 376
                     return false;
377 377
                 }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 
397 397
         if ($mode == 'editable') {
398 398
             $vue->setEditableTemplate(
399
-                function (FrameworkVue $vue, array $data, Model $m) use ($stub) {
399
+                function(FrameworkVue $vue, array $data, Model $m) use ($stub) {
400 400
                     return $this->generator->templateCallback($stub, $vue, $data, $m);
401 401
                 }
402 402
             );
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
             );
411 411
         } else {
412 412
             $vue->setViewableTemplate(
413
-                function (FrameworkVue $vue, array $data, Model $m) use ($stub) {
413
+                function(FrameworkVue $vue, array $data, Model $m) use ($stub) {
414 414
                     return $this->generator->templateCallback($stub, $vue, $data, $m);
415 415
                 }
416 416
             );
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
         $path = $this->generator->getModel()->getName() . '/index.js';
433 433
         $name = $this->generator->getStudlyName();
434 434
 
435
-        $contents = function ($basepath, $element) use ($name) {
435
+        $contents = function($basepath, $element) use ($name) {
436 436
             $dir = $basepath . '/' . $name;
437 437
             $import = [];
438 438
             $export = [];
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
         $path = $this->generator->getModel()->getName() . '/index.dynamic.js';
463 463
         $name = $this->generator->getStudlyName();
464 464
 
465
-        $contents = function ($basepath, $element) use ($name) {
465
+        $contents = function($basepath, $element) use ($name) {
466 466
             $dir = $basepath . '/' . $name;
467 467
             $import = [];
468 468
             $export = [];
Please login to merge, or discard this patch.