@@ -34,7 +34,7 @@ |
||
34 | 34 | $config['type'] = $this->getType(); |
35 | 35 | $config['name'] = $this->getName(); |
36 | 36 | if (empty($config['name'])) { |
37 | - $config['name'] =$this->getAutoName(); |
|
37 | + $config['name'] = $this->getAutoName(); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $validator = ConfigValidator::getInstance(); |
60 | 60 | |
61 | 61 | if (!$validator->validate($this->data, $this->getContextRules(), $this->extraFieldsAllowed)) { |
62 | - throw new ConfigurationException('Config is not valid for ' . ($this->contextObject ? get_class($this->contextObject) : null) . "\n" . implode("\n", $validator->getErrorsArray(false))); |
|
62 | + throw new ConfigurationException('Config is not valid for '.($this->contextObject ? get_class($this->contextObject) : null)."\n".implode("\n", $validator->getErrorsArray(false))); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } elseif (substr($method, 0, 2) == 'is') { |
152 | 152 | $propertyName = lcfirst(substr($method, 2)); |
153 | 153 | } else { |
154 | - throw new \Exception('Call to undefined method ' . $method); |
|
154 | + throw new \Exception('Call to undefined method '.$method); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $this->get($propertyName); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | public function testConfigNoFields() |
32 | 32 | { |
33 | 33 | ConfigValidator::getInstance()->assertValidateConfig( |
34 | - new InterfaceTypeConfig(['name' => 'Test', 'resolveType' => function () { }], null, true) |
|
34 | + new InterfaceTypeConfig(['name' => 'Test', 'resolveType' => function() { }], null, true) |
|
35 | 35 | ); |
36 | 36 | } |
37 | 37 | |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | $interfaceConfig = new InterfaceTypeConfig([ |
60 | 60 | 'name' => 'Test', |
61 | 61 | 'fields' => ['id' => new IntType()], |
62 | - 'resolveType' => function ($object) { |
|
62 | + 'resolveType' => function($object) { |
|
63 | 63 | return $object->getType(); |
64 | 64 | } |
65 | 65 | ], null, true); |
66 | - $object = new ObjectType(['name' => 'User', 'fields' => ['name' => new StringType()]]); |
|
66 | + $object = new ObjectType(['name' => 'User', 'fields' => ['name' => new StringType()]]); |
|
67 | 67 | |
68 | 68 | $this->assertEquals($interfaceConfig->getName(), 'Test'); |
69 | 69 | $this->assertEquals($interfaceConfig->resolveType($object), $object->getType()); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | ] |
79 | 79 | ]); |
80 | 80 | |
81 | - $finalConfig = new TestConfig(['name' => $name . 'final', 'resolve' => function () { return []; }], $object, true); |
|
81 | + $finalConfig = new TestConfig(['name' => $name.'final', 'resolve' => function() { return []; }], $object, true); |
|
82 | 82 | $this->assertEquals($finalConfig->getType(), null); |
83 | 83 | |
84 | 84 | $rules['resolve']['required'] = true; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function testFinalRule() |
100 | 100 | { |
101 | - ConfigValidator::getInstance()->assertValidateConfig(new TestConfig(['name' => 'Test' . 'final'], null, true)); |
|
101 | + ConfigValidator::getInstance()->assertValidateConfig(new TestConfig(['name' => 'Test'.'final'], null, true)); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $isValid = is_null($value) || is_array($value) || $this->isIterableObject($value); |
36 | 36 | $itemType = $this->config->get('itemType'); |
37 | 37 | if ($isValid && $itemType->isInputType()) { |
38 | - foreach($value as $item) { |
|
38 | + foreach ($value as $item) { |
|
39 | 39 | $isValid = $itemType->isValidValue($item); |
40 | 40 | if (!$isValid) return false; |
41 | 41 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | private function isIterableObject($value) |
47 | 47 | { |
48 | - if(is_object($value)) { |
|
48 | + if (is_object($value)) { |
|
49 | 49 | $implements = class_implements($value); |
50 | 50 | return isset($implements['Iterator']) || isset($implements['IteratorAggregate']); |
51 | 51 | } |
@@ -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; |