@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | 'fields' => [ |
96 | 96 | 'list' => [ |
97 | 97 | 'type' => new ListType(new StringType()), |
98 | - 'resolve' => function () { |
|
98 | + 'resolve' => function() { |
|
99 | 99 | return null; |
100 | 100 | } |
101 | 101 | ] |
102 | 102 | ] |
103 | 103 | ]) |
104 | 104 | ])); |
105 | - $data = $processor->processPayload(' { list }')->getResponseData(); |
|
105 | + $data = $processor->processPayload(' { list }')->getResponseData(); |
|
106 | 106 | $this->assertEquals(['data' => ['list' => null]], $data); |
107 | 107 | } |
108 | 108 | |
@@ -115,20 +115,20 @@ discard block |
||
115 | 115 | 'fields' => [ |
116 | 116 | 'list' => [ |
117 | 117 | 'type' => new ListType(new StringType()), |
118 | - 'resolve' => function () { |
|
118 | + 'resolve' => function() { |
|
119 | 119 | return null; |
120 | 120 | } |
121 | 121 | ] |
122 | 122 | ] |
123 | 123 | ]) |
124 | 124 | ])); |
125 | - $data = $processor->processPayload(' { __schema { subscriptionType { name } } }')->getResponseData(); |
|
125 | + $data = $processor->processPayload(' { __schema { subscriptionType { name } } }')->getResponseData(); |
|
126 | 126 | $this->assertEquals(['data' => ['__schema' => ['subscriptionType' => null]]], $data); |
127 | 127 | } |
128 | 128 | |
129 | 129 | public function testSchemaOperations() |
130 | 130 | { |
131 | - $schema = new Schema([ |
|
131 | + $schema = new Schema([ |
|
132 | 132 | 'query' => new ObjectType([ |
133 | 133 | 'name' => 'RootQuery', |
134 | 134 | 'fields' => [ |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | 'args' => [ |
142 | 142 | 'shorten' => new BooleanType() |
143 | 143 | ], |
144 | - 'resolve' => function ($value, $args) { |
|
144 | + 'resolve' => function($value, $args) { |
|
145 | 145 | return empty($args['shorten']) ? $value['firstName'] : $value['firstName']; |
146 | 146 | } |
147 | 147 | ], |
148 | 148 | 'id_alias' => [ |
149 | 149 | 'type' => new IdType(), |
150 | - 'resolve' => function ($value) { |
|
150 | + 'resolve' => function($value) { |
|
151 | 151 | return $value['id']; |
152 | 152 | } |
153 | 153 | ], |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | 'code' => new StringType(), |
156 | 156 | ] |
157 | 157 | ]), |
158 | - 'resolve' => function ($value, $args) { |
|
158 | + 'resolve' => function($value, $args) { |
|
159 | 159 | $data = ['id' => '123', 'firstName' => 'John', 'code' => '007']; |
160 | 160 | if (!empty($args['upper'])) { |
161 | 161 | foreach ($data as $key => $value) { |
@@ -174,19 +174,19 @@ discard block |
||
174 | 174 | ], |
175 | 175 | 'randomUser' => [ |
176 | 176 | 'type' => new TestObjectType(), |
177 | - 'resolve' => function () { |
|
177 | + 'resolve' => function() { |
|
178 | 178 | return ['invalidField' => 'John']; |
179 | 179 | } |
180 | 180 | ], |
181 | 181 | 'invalidValueQuery' => [ |
182 | 182 | 'type' => new TestObjectType(), |
183 | - 'resolve' => function () { |
|
183 | + 'resolve' => function() { |
|
184 | 184 | return 'stringValue'; |
185 | 185 | } |
186 | 186 | ], |
187 | 187 | 'labels' => [ |
188 | 188 | 'type' => new ListType(new StringType()), |
189 | - 'resolve' => function () { |
|
189 | + 'resolve' => function() { |
|
190 | 190 | return ['one', 'two']; |
191 | 191 | } |
192 | 192 | ] |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | ->addField(new Field([ |
218 | 218 | 'name' => 'increaseCounter', |
219 | 219 | 'type' => new IntType(), |
220 | - 'resolve' => function ($value, $args, ResolveInfo $info) { |
|
220 | + 'resolve' => function($value, $args, ResolveInfo $info) { |
|
221 | 221 | return $this->_counter += $args['amount']; |
222 | 222 | }, |
223 | 223 | 'args' => [ |
@@ -229,13 +229,13 @@ discard block |
||
229 | 229 | ]))->addField(new Field([ |
230 | 230 | 'name' => 'invalidResolveTypeMutation', |
231 | 231 | 'type' => new NonNullType(new IntType()), |
232 | - 'resolve' => function () { |
|
232 | + 'resolve' => function() { |
|
233 | 233 | return null; |
234 | 234 | } |
235 | 235 | ]))->addField(new Field([ |
236 | 236 | 'name' => 'interfacedMutation', |
237 | 237 | 'type' => new TestInterfaceType(), |
238 | - 'resolve' => function () { |
|
238 | + 'resolve' => function() { |
|
239 | 239 | return ['name' => 'John']; |
240 | 240 | } |
241 | 241 | ])); |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | ])) |
305 | 305 | ], |
306 | 306 | 'type' => new StringType(), |
307 | - 'resolve' => function ($value, $args) { |
|
307 | + 'resolve' => function($value, $args) { |
|
308 | 308 | return $args['argument1']; |
309 | 309 | } |
310 | 310 | ] |
@@ -340,43 +340,43 @@ discard block |
||
340 | 340 | 'fields' => [ |
341 | 341 | 'listQuery' => [ |
342 | 342 | 'type' => new ListType(new TestEnumType()), |
343 | - 'resolve' => function () { |
|
343 | + 'resolve' => function() { |
|
344 | 344 | return 'invalid list'; |
345 | 345 | } |
346 | 346 | ], |
347 | 347 | 'listEnumQuery' => [ |
348 | 348 | 'type' => new ListType(new TestEnumType()), |
349 | - 'resolve' => function () { |
|
349 | + 'resolve' => function() { |
|
350 | 350 | return ['invalid enum']; |
351 | 351 | } |
352 | 352 | ], |
353 | 353 | 'invalidEnumQuery' => [ |
354 | 354 | 'type' => new TestEnumType(), |
355 | - 'resolve' => function () { |
|
355 | + 'resolve' => function() { |
|
356 | 356 | return 'invalid enum'; |
357 | 357 | } |
358 | 358 | ], |
359 | 359 | 'enumQuery' => [ |
360 | 360 | 'type' => new TestEnumType(), |
361 | - 'resolve' => function () { |
|
361 | + 'resolve' => function() { |
|
362 | 362 | return 1; |
363 | 363 | } |
364 | 364 | ], |
365 | 365 | 'invalidNonNullQuery' => [ |
366 | 366 | 'type' => new NonNullType(new IntType()), |
367 | - 'resolve' => function () { |
|
367 | + 'resolve' => function() { |
|
368 | 368 | return null; |
369 | 369 | } |
370 | 370 | ], |
371 | 371 | 'invalidNonNullInsideQuery' => [ |
372 | 372 | 'type' => new NonNullType(new IntType()), |
373 | - 'resolve' => function () { |
|
373 | + 'resolve' => function() { |
|
374 | 374 | return 'hello'; |
375 | 375 | } |
376 | 376 | ], |
377 | 377 | 'objectQuery' => [ |
378 | 378 | 'type' => new TestObjectType(), |
379 | - 'resolve' => function () { |
|
379 | + 'resolve' => function() { |
|
380 | 380 | return ['name' => 'John']; |
381 | 381 | } |
382 | 382 | ], |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | 'enum' => new TestEnumType(), |
389 | 389 | ], |
390 | 390 | ]), |
391 | - 'resolve' => function () { |
|
391 | + 'resolve' => function() { |
|
392 | 392 | return [ |
393 | 393 | 'object' => [ |
394 | 394 | 'name' => 'John' |
@@ -462,10 +462,10 @@ discard block |
||
462 | 462 | ] |
463 | 463 | ]); |
464 | 464 | |
465 | - $union = new UnionType([ |
|
465 | + $union = new UnionType([ |
|
466 | 466 | 'name' => 'TestUnion', |
467 | 467 | 'types' => [$object1, $object2], |
468 | - 'resolveType' => function ($object) use ($object1, $object2) { |
|
468 | + 'resolveType' => function($object) use ($object1, $object2) { |
|
469 | 469 | if (isset($object['id'])) { |
470 | 470 | return $object1; |
471 | 471 | } |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | $invalidUnion = new UnionType([ |
477 | 477 | 'name' => 'TestUnion', |
478 | 478 | 'types' => [$object1, $object2], |
479 | - 'resolveType' => function ($object) use ($object3) { |
|
479 | + 'resolveType' => function($object) use ($object3) { |
|
480 | 480 | return $object3; |
481 | 481 | } |
482 | 482 | ]); |
483 | - $processor = new Processor(new Schema([ |
|
483 | + $processor = new Processor(new Schema([ |
|
484 | 484 | 'query' => new ObjectType([ |
485 | 485 | 'name' => 'RootQuery', |
486 | 486 | 'fields' => [ |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | 'type' => ['type' => 'string'] |
491 | 491 | ], |
492 | 492 | 'cost' => 10, |
493 | - 'resolve' => function ($value, $args) { |
|
493 | + 'resolve' => function($value, $args) { |
|
494 | 494 | if ($args['type'] == 'object1') { |
495 | 495 | return [ |
496 | 496 | 'id' => 43 |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | ], |
505 | 505 | 'invalidUnion' => [ |
506 | 506 | 'type' => $invalidUnion, |
507 | - 'resolve' => function () { |
|
507 | + 'resolve' => function() { |
|
508 | 508 | return ['name' => 'name resolved']; |
509 | 509 | } |
510 | 510 | ], |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | 'fields' => [ |
560 | 560 | 'currentUser' => [ |
561 | 561 | 'type' => new StringType(), |
562 | - 'resolve' => function ($source, $args, ResolveInfo $info) { |
|
562 | + 'resolve' => function($source, $args, ResolveInfo $info) { |
|
563 | 563 | return $info->getContainer()->get('user')['name']; |
564 | 564 | } |
565 | 565 | ] |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | |
578 | 578 | public function testComplexityReducer() |
579 | 579 | { |
580 | - $schema = new Schema( |
|
580 | + $schema = new Schema( |
|
581 | 581 | [ |
582 | 582 | 'query' => new ObjectType( |
583 | 583 | [ |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | 'args' => [ |
594 | 594 | 'shorten' => new BooleanType() |
595 | 595 | ], |
596 | - 'resolve' => function ($value, $args) { |
|
596 | + 'resolve' => function($value, $args) { |
|
597 | 597 | return empty($args['shorten']) ? $value : $value; |
598 | 598 | } |
599 | 599 | ], |
@@ -602,19 +602,19 @@ discard block |
||
602 | 602 | 'likes' => [ |
603 | 603 | 'type' => new IntType(), |
604 | 604 | 'cost' => 10, |
605 | - 'resolve' => function () { |
|
605 | + 'resolve' => function() { |
|
606 | 606 | return 42; |
607 | 607 | } |
608 | 608 | ] |
609 | 609 | ] |
610 | 610 | ] |
611 | 611 | ), |
612 | - 'cost' => function ($args, $context, $childCost) { |
|
612 | + 'cost' => function($args, $context, $childCost) { |
|
613 | 613 | $argsCost = isset($args['cost']) ? $args['cost'] : 1; |
614 | 614 | |
615 | 615 | return 1 + $argsCost * $childCost; |
616 | 616 | }, |
617 | - 'resolve' => function ($value, $args) { |
|
617 | + 'resolve' => function($value, $args) { |
|
618 | 618 | $data = ['firstName' => 'John', 'code' => '007']; |
619 | 619 | |
620 | 620 | return $data; |
@@ -47,7 +47,7 @@ |
||
47 | 47 | if (isset($this->values[$id])) { |
48 | 48 | unset($this->values[$id]); |
49 | 49 | } |
50 | - $this->keyset[$id] = true; |
|
50 | + $this->keyset[$id] = true; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | public function remove($id) |
@@ -53,7 +53,7 @@ |
||
53 | 53 | public function testSetVariableParseJson() |
54 | 54 | { |
55 | 55 | $variables = '{"foo": "bar"}'; |
56 | - $expectedVariableArray = [ 'foo' => 'bar' ]; |
|
56 | + $expectedVariableArray = ['foo' => 'bar']; |
|
57 | 57 | |
58 | 58 | $request = new Request([], $variables); |
59 | 59 | $this->assertEquals($expectedVariableArray, $request->getVariables()); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | 'args' => [ |
37 | 37 | 'episode' => ['type' => new EpisodeEnum()] |
38 | 38 | ], |
39 | - 'resolve' => function ($root, $args) { |
|
39 | + 'resolve' => function($root, $args) { |
|
40 | 40 | return StarWarsData::getHero(isset($args['episode']) ? $args['episode'] : null); |
41 | 41 | }, |
42 | 42 | ]) |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | 'args' => [ |
47 | 47 | 'id' => new IdType() |
48 | 48 | ], |
49 | - 'resolve' => function ($value = null, $args = []) { |
|
49 | + 'resolve' => function($value = null, $args = []) { |
|
50 | 50 | $humans = StarWarsData::humans(); |
51 | 51 | |
52 | 52 | return isset($humans[$args['id']]) ? $humans[$args['id']] : null; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'args' => [ |
59 | 59 | 'id' => new IdType() |
60 | 60 | ], |
61 | - 'resolve' => function ($value = null, $args = []) { |
|
61 | + 'resolve' => function($value = null, $args = []) { |
|
62 | 62 | $droids = StarWarsData::droids(); |
63 | 63 | |
64 | 64 | return isset($droids[$args['id']]) ? $droids[$args['id']] : null; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $edgeFields = !empty($config['edgeFields']) ? $config['edgeFields'] : []; |
53 | 53 | |
54 | 54 | $edgeType = new ObjectType([ |
55 | - 'name' => $name . 'Edge', |
|
55 | + 'name' => $name.'Edge', |
|
56 | 56 | 'description' => 'An edge in a connection.', |
57 | 57 | 'fields' => array_merge([ |
58 | 58 | 'node' => [ |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $connectionFields = !empty($config['connectionFields']) ? $config['connectionFields'] : []; |
85 | 85 | |
86 | 86 | $connectionType = new ObjectType([ |
87 | - 'name' => $name . 'Connection', |
|
87 | + 'name' => $name.'Connection', |
|
88 | 88 | 'description' => 'A connection to a list of items.', |
89 | 89 | 'fields' => array_merge([ |
90 | 90 | 'pageInfo' => [ |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | public function isValidValue($value) |
44 | 44 | { |
45 | - if($value instanceof InputObject) { |
|
45 | + if ($value instanceof InputObject) { |
|
46 | 46 | $value = $value->getValue(); |
47 | 47 | } |
48 | 48 | |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | $typeConfig = $this->getConfig(); |
54 | - $requiredFields = array_filter($typeConfig->getFields(), function (FieldInterface $field) { |
|
54 | + $requiredFields = array_filter($typeConfig->getFields(), function(FieldInterface $field) { |
|
55 | 55 | return $field->getType()->getKind() == TypeMap::KIND_NON_NULL; |
56 | 56 | }); |
57 | 57 | |
58 | 58 | foreach ($value as $valueKey => $valueItem) { |
59 | - if($valueItem instanceof Variable) { |
|
59 | + if ($valueItem instanceof Variable) { |
|
60 | 60 | $valueItem = $valueItem->getValue(); |
61 | 61 | } |
62 | 62 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | $typeConfig = $this->getConfig(); |
88 | 88 | foreach ($value as $valueKey => $item) { |
89 | - if($item instanceof Variable) { |
|
89 | + if ($item instanceof Variable) { |
|
90 | 90 | $item = $item->getValue(); |
91 | 91 | } |
92 | 92 |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function validateArguments(FieldInterface $field, $query, Request $request) |
67 | 67 | { |
68 | - $requiredArguments = array_filter($field->getArguments(), function (InputField $argument) { |
|
68 | + $requiredArguments = array_filter($field->getArguments(), function(InputField $argument) { |
|
69 | 69 | return $argument->getType()->getKind() == TypeMap::KIND_NON_NULL; |
70 | 70 | }); |
71 | 71 | |
72 | - $withDefaultArguments = array_filter($field->getArguments(), function (InputField $argument) { |
|
72 | + $withDefaultArguments = array_filter($field->getArguments(), function(InputField $argument) { |
|
73 | 73 | return $argument->getConfig()->get('default') !== null; |
74 | 74 | }); |
75 | 75 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | foreach ($argument->getValue()->getValue() as $item) { |
97 | - if(!$this->processInputObject($item, $argumentType, $request)) { |
|
97 | + if (!$this->processInputObject($item, $argumentType, $request)) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | public function assertTypeImplementsInterface(AbstractType $type, AbstractInterfaceType $interface) |
187 | 187 | { |
188 | 188 | if (!$interface->isValidValue($type)) { |
189 | - throw new ResolveException('Type ' . $type->getName() . ' does not implement ' . $interface->getName()); |
|
189 | + throw new ResolveException('Type '.$type->getName().' does not implement '.$interface->getName()); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | if (!$valid) { |
208 | - throw new ResolveException('Type ' . $type->getName() . ' not exist in types of ' . $unionType->getName()); |
|
208 | + throw new ResolveException('Type '.$type->getName().' not exist in types of '.$unionType->getName()); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | if (!is_array($types)) { |
25 | 25 | throw new \Exception('addTypes accept only array of types'); |
26 | 26 | } |
27 | - foreach($types as $type) { |
|
27 | + foreach ($types as $type) { |
|
28 | 28 | $this->addType($type); |
29 | 29 | } |
30 | 30 | return $this; |