Passed
Pull Request — master (#190)
by Sebastian
03:03
created
src/Schema/Validation/Rule/SupportedRules.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@
 block discarded – undo
11 11
      * @var array
12 12
      */
13 13
     private static $supportedRules = [
14
-      RootTypesRule::class,
15
-      DirectivesRule::class,
16
-      TypesRule::class,
14
+        RootTypesRule::class,
15
+        DirectivesRule::class,
16
+        TypesRule::class,
17 17
     ];
18 18
 
19 19
     /**
Please login to merge, or discard this patch.
src/Schema/Validation/Rule/RootTypesRule.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
         $schema = $this->context->getSchema();
23 23
 
24 24
         $rootTypes = [
25
-          'query' => $schema->getQueryType(),
26
-          'mutation' => $schema->getMutationType(),
27
-          'subscription' => $schema->getSubscriptionType(),
25
+            'query' => $schema->getQueryType(),
26
+            'mutation' => $schema->getMutationType(),
27
+            'subscription' => $schema->getSubscriptionType(),
28 28
         ];
29 29
 
30 30
         foreach ($rootTypes as $operation => $rootType) {
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
      */
39 39
     protected function validateRootType(
40 40
       ?TypeInterface $rootType,
41
-      string $operation
41
+        string $operation
42 42
     ): void {
43 43
         $schema = $this->context->getSchema();
44 44
 
45 45
         if ($operation === 'query' && null === $rootType) {
46 46
             $this->context->reportError(
47
-              new SchemaValidationException(
47
+                new SchemaValidationException(
48 48
                 \sprintf('%s root type must be provided.',
49
-                  \ucfirst($operation)),
49
+                    \ucfirst($operation)),
50 50
                 $schema->hasAstNode() ? [$schema->getAstNode()] : null
51
-              )
51
+                )
52 52
             );
53 53
 
54 54
             return;
@@ -56,18 +56,18 @@  discard block
 block discarded – undo
56 56
 
57 57
         if (null !== $rootType && !($rootType instanceof ObjectType)) {
58 58
             $this->context->reportError(
59
-              new SchemaValidationException(
59
+                new SchemaValidationException(
60 60
                 \sprintf(
61
-                  $operation === 'query'
61
+                    $operation === 'query'
62 62
                     ? '%s root type must be Object type, it cannot be %s.'
63 63
                     : '%s root type must be Object type if provided, it cannot be %s.',
64
-                  \ucfirst($operation),
65
-                  (string)$rootType
64
+                    \ucfirst($operation),
65
+                    (string)$rootType
66 66
                 ),
67 67
                 null !== $rootType ? [
68
-                  $this->getOperationTypeNode($schema, $rootType, $operation),
68
+                    $this->getOperationTypeNode($schema, $rootType, $operation),
69 69
                 ] : null
70
-              )
70
+                )
71 71
             );
72 72
 
73 73
             return;
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
      * @return NodeInterface|null
83 83
      */
84 84
     protected function getOperationTypeNode(
85
-      SchemaInterface $schema,
86
-      TypeInterface $type,
87
-      string $operation
85
+        SchemaInterface $schema,
86
+        TypeInterface $type,
87
+        string $operation
88 88
     ): ?NodeInterface
89 89
     {
90 90
         /** @var SchemaDefinitionNode $node */
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 
97 97
         /** @var OperationTypeDefinitionNode $operationTypeNode */
98 98
         $operationTypeNode = find(
99
-          $node->getOperationTypes(),
100
-          function (OperationTypeDefinitionNode $operationType) use ($operation
101
-          ) {
102
-              return $operationType->getOperation() === $operation;
103
-          }
99
+            $node->getOperationTypes(),
100
+            function (OperationTypeDefinitionNode $operationType) use ($operation
101
+            ) {
102
+                return $operationType->getOperation() === $operation;
103
+            }
104 104
         );
105 105
 
106 106
         return $operationTypeNode->getType();
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
         /** @var OperationTypeDefinitionNode $operationTypeNode */
98 98
         $operationTypeNode = find(
99 99
           $node->getOperationTypes(),
100
-          function (OperationTypeDefinitionNode $operationType) use ($operation
100
+          function(OperationTypeDefinitionNode $operationType) use ($operation
101 101
           ) {
102 102
               return $operationType->getOperation() === $operation;
103 103
           }
Please login to merge, or discard this patch.
src/Schema/Validation/SchemaValidatorInterface.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
      * @return SchemaValidationException[]
17 17
      */
18 18
     public function validate(
19
-      SchemaInterface $schema,
19
+        SchemaInterface $schema,
20 20
       ?array $rules = null
21 21
     ): array;
22 22
 
Please login to merge, or discard this patch.
src/Schema/Schema.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
     public function getDirective(string $name): ?Directive
138 138
     {
139 139
         return find($this->directives,
140
-          function (Directive $directive) use ($name) {
141
-              return $directive->getName() === $name;
142
-          });
140
+            function (Directive $directive) use ($name) {
141
+                return $directive->getName() === $name;
142
+            });
143 143
     }
144 144
 
145 145
     /**
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
      * @inheritdoc
193 193
      */
194 194
     public function isPossibleType(
195
-      AbstractTypeInterface $abstractType,
196
-      TypeInterface $possibleType
195
+        AbstractTypeInterface $abstractType,
196
+        TypeInterface $possibleType
197 197
     ): bool {
198 198
         /** @noinspection PhpUndefinedMethodInspection */
199 199
         $abstractTypeName = $abstractType->getName();
@@ -204,21 +204,21 @@  discard block
 block discarded – undo
204 204
             $possibleTypes = $this->getPossibleTypes($abstractType);
205 205
 
206 206
             invariant(
207
-              \is_array($possibleTypes),
208
-              \sprintf(
207
+                \is_array($possibleTypes),
208
+                \sprintf(
209 209
                 'Could not find possible implementing types for %s ' .
210 210
                 'in schema. Check that schema.types is defined and is an array of ' .
211 211
                 'all possible types in the schema.',
212 212
                 $abstractTypeName
213
-              )
213
+                )
214 214
             );
215 215
 
216 216
             $this->possibleTypesMap[$abstractTypeName] = \array_reduce($possibleTypes,
217
-              function (array $map, TypeInterface $type) {
218
-                  /** @var NameAwareInterface $type */
219
-                  $map[$type->getName()] = true;
220
-                  return $map;
221
-              }, []);
217
+                function (array $map, TypeInterface $type) {
218
+                    /** @var NameAwareInterface $type */
219
+                    $map[$type->getName()] = true;
220
+                    return $map;
221
+                }, []);
222 222
         }
223 223
 
224 224
         return isset($this->possibleTypesMap[$abstractTypeName][$possibleTypeName]);
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
     protected function buildTypeMap(): void
269 269
     {
270 270
         $initialTypes = [
271
-          $this->query,
272
-          $this->mutation,
273
-          $this->subscription,
274
-          __Schema(), // Introspection
271
+            $this->query,
272
+            $this->mutation,
273
+            $this->subscription,
274
+            __Schema(), // Introspection
275 275
         ];
276 276
 
277 277
         if ($this->types) {
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 
284 284
         // First by deeply visiting all initial types.
285 285
         $typeMap = \array_reduce($initialTypes, [$this, 'typeMapReducer'],
286
-          $typeMap);
286
+            $typeMap);
287 287
 
288 288
         // Then by deeply visiting all directive types.
289 289
         $typeMap = \array_reduce($this->directives,
290
-          [$this, 'typeMapDirectiveReducer'], $typeMap);
290
+            [$this, 'typeMapDirectiveReducer'], $typeMap);
291 291
 
292 292
         // Storing the resulting map for reference by the schema.
293 293
         $this->typeMap = $typeMap;
@@ -383,9 +383,9 @@  discard block
 block discarded – undo
383 383
         }
384 384
 
385 385
         return \array_reduce($directive->getArguments(),
386
-          function ($map, Argument $argument) {
387
-              return $this->typeMapReducer($map, $argument->getType());
388
-          }, $map);
386
+            function ($map, Argument $argument) {
387
+                return $this->typeMapReducer($map, $argument->getType());
388
+            }, $map);
389 389
     }
390 390
 
391 391
     /**
@@ -409,11 +409,11 @@  discard block
 block discarded – undo
409 409
 
410 410
         if (isset($map[$typeName])) {
411 411
             invariant(
412
-              $type === $map[$typeName],
413
-              \sprintf(
412
+                $type === $map[$typeName],
413
+                \sprintf(
414 414
                 'Schema must contain unique named types but contains multiple types named "%s".',
415 415
                 $type->getName()
416
-              )
416
+                )
417 417
             );
418 418
 
419 419
             return $map;
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
 
426 426
         if ($type instanceof UnionType) {
427 427
             $reducedMap = \array_reduce($type->getTypes(),
428
-              [$this, 'typeMapReducer'], $reducedMap);
428
+                [$this, 'typeMapReducer'], $reducedMap);
429 429
         }
430 430
 
431 431
         if ($type instanceof ObjectType) {
432 432
             $reducedMap = \array_reduce($type->getInterfaces(),
433
-              [$this, 'typeMapReducer'], $reducedMap);
433
+                [$this, 'typeMapReducer'], $reducedMap);
434 434
         }
435 435
 
436 436
         if ($type instanceof ObjectType || $type instanceof InterfaceType) {
@@ -441,18 +441,18 @@  discard block
 block discarded – undo
441 441
                     }, $field->getArguments());
442 442
 
443 443
                     $reducedMap = \array_reduce($fieldArgTypes,
444
-                      [$this, 'typeMapReducer'], $reducedMap);
444
+                        [$this, 'typeMapReducer'], $reducedMap);
445 445
                 }
446 446
 
447 447
                 $reducedMap = $this->typeMapReducer($reducedMap,
448
-                  $field->getType());
448
+                    $field->getType());
449 449
             }
450 450
         }
451 451
 
452 452
         if ($type instanceof InputObjectType) {
453 453
             foreach ($type->getFields() as $field) {
454 454
                 $reducedMap = $this->typeMapReducer($reducedMap,
455
-                  $field->getType());
455
+                    $field->getType());
456 456
             }
457 457
         }
458 458
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     public function getDirective(string $name): ?Directive
138 138
     {
139 139
         return find($this->directives,
140
-          function (Directive $directive) use ($name) {
140
+          function(Directive $directive) use ($name) {
141 141
               return $directive->getName() === $name;
142 142
           });
143 143
     }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
             );
215 215
 
216 216
             $this->possibleTypesMap[$abstractTypeName] = \array_reduce($possibleTypes,
217
-              function (array $map, TypeInterface $type) {
217
+              function(array $map, TypeInterface $type) {
218 218
                   /** @var NameAwareInterface $type */
219 219
                   $map[$type->getName()] = true;
220 220
                   return $map;
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
         }
384 384
 
385 385
         return \array_reduce($directive->getArguments(),
386
-          function ($map, Argument $argument) {
386
+          function($map, Argument $argument) {
387 387
               return $this->typeMapReducer($map, $argument->getType());
388 388
           }, $map);
389 389
     }
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
         if ($type instanceof ObjectType || $type instanceof InterfaceType) {
437 437
             foreach ($type->getFields() as $field) {
438 438
                 if ($field->hasArguments()) {
439
-                    $fieldArgTypes = \array_map(function (Argument $argument) {
439
+                    $fieldArgTypes = \array_map(function(Argument $argument) {
440 440
                         return $argument->getType();
441 441
                     }, $field->getArguments());
442 442
 
Please login to merge, or discard this patch.
src/Schema/Building/BuildInfo.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@
 block discarded – undo
48 48
      * @param SchemaDefinitionNode|null $schemaDefinition
49 49
      */
50 50
     public function __construct(
51
-      DocumentNode $document,
52
-      array $typeDefinitionMap,
53
-      array $directiveDefinitions,
54
-      array $operationTypeDefinitions,
51
+        DocumentNode $document,
52
+        array $typeDefinitionMap,
53
+        array $directiveDefinitions,
54
+        array $operationTypeDefinitions,
55 55
       ?SchemaDefinitionNode $schemaDefinition = null
56 56
     ) {
57 57
         $this->document = $document;
Please login to merge, or discard this patch.
src/Schema/Building/SchemaBuilder.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -37,20 +37,20 @@  discard block
 block discarded – undo
37 37
      * @inheritdoc
38 38
      */
39 39
     public function build(
40
-      DocumentNode $document,
41
-      ResolverRegistryInterface $resolverRegistry,
42
-      array $options = []
40
+        DocumentNode $document,
41
+        ResolverRegistryInterface $resolverRegistry,
42
+        array $options = []
43 43
     ): SchemaInterface {
44 44
         $context = $this->createContext($document, $resolverRegistry);
45 45
 
46 46
         return newSchema([
47
-          'query' => $context->buildQueryType(),
48
-          'mutation' => $context->buildMutationType(),
49
-          'subscription' => $context->buildSubscriptionType(),
50
-          'types' => $context->buildTypes(),
51
-          'directives' => $context->buildDirectives(),
52
-          'astNode' => $context->getSchemaDefinition(),
53
-          'assumeValid' => $options['assumeValid'] ?? false,
47
+            'query' => $context->buildQueryType(),
48
+            'mutation' => $context->buildMutationType(),
49
+            'subscription' => $context->buildSubscriptionType(),
50
+            'types' => $context->buildTypes(),
51
+            'directives' => $context->buildDirectives(),
52
+            'astNode' => $context->getSchemaDefinition(),
53
+            'assumeValid' => $options['assumeValid'] ?? false,
54 54
         ]);
55 55
     }
56 56
 
@@ -58,20 +58,20 @@  discard block
 block discarded – undo
58 58
      * @inheritdoc
59 59
      */
60 60
     public function createContext(
61
-      DocumentNode $document,
62
-      ResolverRegistryInterface $resolverRegistry
61
+        DocumentNode $document,
62
+        ResolverRegistryInterface $resolverRegistry
63 63
     ): BuildingContextInterface {
64 64
         $info = $this->createInfo($document);
65 65
 
66 66
         $definitionBuilder = new DefinitionBuilder(
67
-          $info->getTypeDefinitionMap(),
68
-          $resolverRegistry,
69
-          null, // use the default resolveType-function
70
-          $this->cache
67
+            $info->getTypeDefinitionMap(),
68
+            $resolverRegistry,
69
+            null, // use the default resolveType-function
70
+            $this->cache
71 71
         );
72 72
 
73 73
         return new BuildingContext($resolverRegistry, $definitionBuilder,
74
-          $info);
74
+            $info);
75 75
     }
76 76
 
77 77
     /**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
                 if (isset($typeDefinitionMap[$typeName])) {
102 102
                     throw new BuildingException(sprintf('Type "%s" was defined more than once.',
103
-                      $typeName));
103
+                        $typeName));
104 104
                 }
105 105
 
106 106
                 $typeDefinitionMap[$typeName] = $definition;
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
         }
117 117
 
118 118
         return new BuildInfo(
119
-          $document,
120
-          $typeDefinitionMap,
121
-          $directiveDefinitions,
122
-          null !== $schemaDefinition ? $this->getOperationTypeDefinitions($schemaDefinition,
119
+            $document,
120
+            $typeDefinitionMap,
121
+            $directiveDefinitions,
122
+            null !== $schemaDefinition ? $this->getOperationTypeDefinitions($schemaDefinition,
123 123
             $typeDefinitionMap) : [],
124
-          $schemaDefinition
124
+            $schemaDefinition
125 125
         );
126 126
     }
127 127
 
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
      * @throws BuildingException
133 133
      */
134 134
     protected function getOperationTypeDefinitions(
135
-      SchemaDefinitionNode $node,
136
-      array $typeDefinitionMap
135
+        SchemaDefinitionNode $node,
136
+        array $typeDefinitionMap
137 137
     ): array {
138 138
         $definitions = [];
139 139
 
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 
146 146
             if (isset($definitions[$typeName])) {
147 147
                 throw new BuildingException(
148
-                  \sprintf('Must provide only one %s type in schema.',
148
+                    \sprintf('Must provide only one %s type in schema.',
149 149
                     $operation)
150 150
                 );
151 151
             }
152 152
 
153 153
             if (!isset($typeDefinitionMap[$typeName])) {
154 154
                 throw new BuildingException(
155
-                  \sprintf('Specified %s type %s not found in document.',
155
+                    \sprintf('Specified %s type %s not found in document.',
156 156
                     $operation, $typeName)
157 157
                 );
158 158
             }
Please login to merge, or discard this patch.
src/Schema/Building/SchemaBuildingProvider.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
      * @var array
13 13
      */
14 14
     protected $provides = [
15
-      SchemaBuilderInterface::class,
15
+        SchemaBuilderInterface::class,
16 16
     ];
17 17
 
18 18
     /**
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     public function register()
22 22
     {
23 23
         $this->container->add(SchemaBuilderInterface::class,
24
-          SchemaBuilder::class)
25
-          ->withArgument(CacheInterface::class);
24
+            SchemaBuilder::class)
25
+            ->withArgument(CacheInterface::class);
26 26
     }
27 27
 }
Please login to merge, or discard this patch.
src/Schema/Building/BuildingContext.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
      * @param BuildInfo $info
38 38
      */
39 39
     public function __construct(
40
-      ResolverRegistryInterface $resolverRegistry,
41
-      DefinitionBuilderInterface $definitionBuilder,
42
-      BuildInfo $info
40
+        ResolverRegistryInterface $resolverRegistry,
41
+        DefinitionBuilderInterface $definitionBuilder,
42
+        BuildInfo $info
43 43
     ) {
44 44
         $this->resolverRegistry = $resolverRegistry;
45 45
         $this->definitionBuilder = $definitionBuilder;
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
         }, $this->info->getDirectiveDefinitions());
95 95
 
96 96
         $specifiedDirectivesMap = [
97
-          'skip' => SkipDirective(),
98
-          'include' => IncludeDirective(),
99
-          'deprecated' => DeprecatedDirective(),
97
+            'skip' => SkipDirective(),
98
+            'include' => IncludeDirective(),
99
+            'deprecated' => DeprecatedDirective(),
100 100
         ];
101 101
 
102 102
         foreach ($specifiedDirectivesMap as $name => $directive) {
103 103
             if (!arraySome($directives,
104
-              function (Directive $directive) use ($name) {
105
-                  return $directive->getName() === $name;
106
-              })) {
104
+                function (Directive $directive) use ($name) {
105
+                    return $directive->getName() === $name;
106
+                })) {
107 107
                 $directives[] = $directive;
108 108
             }
109 109
         }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function buildTypes(): array
80 80
     {
81
-        return \array_map(function (TypeDefinitionNodeInterface $definition) {
81
+        return \array_map(function(TypeDefinitionNodeInterface $definition) {
82 82
             return $this->definitionBuilder->buildType($definition);
83 83
         }, \array_values($this->info->getTypeDefinitionMap()));
84 84
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function buildDirectives(): array
90 90
     {
91
-        $directives = \array_map(function (DirectiveDefinitionNode $definition
91
+        $directives = \array_map(function(DirectiveDefinitionNode $definition
92 92
         ) {
93 93
             return $this->definitionBuilder->buildDirective($definition);
94 94
         }, $this->info->getDirectiveDefinitions());
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
         foreach ($specifiedDirectivesMap as $name => $directive) {
103 103
             if (!arraySome($directives,
104
-              function (Directive $directive) use ($name) {
104
+              function(Directive $directive) use ($name) {
105 105
                   return $directive->getName() === $name;
106 106
               })) {
107 107
                 $directives[] = $directive;
Please login to merge, or discard this patch.
src/Schema/Building/SchemaBuilderInterface.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
      * @return SchemaInterface
18 18
      */
19 19
     public function build(
20
-      DocumentNode $document,
21
-      ResolverRegistryInterface $resolverRegistry,
22
-      array $options = []
20
+        DocumentNode $document,
21
+        ResolverRegistryInterface $resolverRegistry,
22
+        array $options = []
23 23
     ): SchemaInterface;
24 24
 
25 25
     /**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @return BuildingContextInterface
30 30
      */
31 31
     public function createContext(
32
-      DocumentNode $document,
33
-      ResolverRegistryInterface $resolverRegistry
32
+        DocumentNode $document,
33
+        ResolverRegistryInterface $resolverRegistry
34 34
     ): BuildingContextInterface;
35 35
 }
Please login to merge, or discard this patch.