Completed
Push — master ( f8e797...0b7ef3 )
by Alexandr
03:58
created
src/Type/InterfaceType/InterfaceType.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -25,6 +25,9 @@
 block discarded – undo
25 25
     {
26 26
     }
27 27
 
28
+    /**
29
+     * @param \Youshido\GraphQL\Type\Object\ObjectType $object
30
+     */
28 31
     public function resolveType($object)
29 32
     {
30 33
         return $this->getConfig()->resolveType($object);
Please login to merge, or discard this patch.
src/Type/NonNullType.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -50,6 +50,9 @@
 block discarded – undo
50 50
         return $value;
51 51
     }
52 52
 
53
+    /**
54
+     * @param null|Scalar\StringType $value
55
+     */
53 56
     public function isValidValue($value)
54 57
     {
55 58
         return $value !== null;
Please login to merge, or discard this patch.
src/Validator/SchemaValidator/SchemaValidator.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
      * @param Field                 $objField
58 58
      * @param AbstractInterfaceType $interface
59 59
      *
60
-     * @return bool
60
+     * @return boolean|null
61 61
      *
62 62
      * @throws ConfigurationException
63 63
      */
Please login to merge, or discard this patch.
Tests/DataProvider/TestField.php 1 patch
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,13 +16,16 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
     /**
19
-     * @return AbstractObjectType
19
+     * @return IntType
20 20
      */
21 21
     public function getType()
22 22
     {
23 23
         return new IntType();
24 24
     }
25 25
 
26
+    /**
27
+     * @param string $value
28
+     */
26 29
     public function resolve($value, array $args, ResolveInfo $info)
27 30
     {
28 31
         return $value;
Please login to merge, or discard this patch.
Tests/DataProvider/TestInputField.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
     /**
19
-     * @return AbstractInputObjectType
19
+     * @return IntType
20 20
      */
21 21
     public function getType()
22 22
     {
Please login to merge, or discard this patch.
Tests/StarWars/Schema/QueryType.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 
10 10
 
11 11
 use Youshido\GraphQL\Field\Field;
12
-use Youshido\GraphQL\Field\FieldFactory;
13 12
 use Youshido\GraphQL\Type\Object\AbstractObjectType;
14 13
 use Youshido\GraphQL\Type\Scalar\IdType;
15 14
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Tests/Schema/ProcessorTest.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -164,19 +164,19 @@
 block discarded – undo
164 164
         $this->assertEquals(['data' => ['me' => ['firstName' => 'JOHN']]], $processor->getResponseData());
165 165
 
166 166
         $schema->getMutationType()
167
-               ->addField(new Field([
168
-                   'name'    => 'increaseCounter',
169
-                   'type'    => new IntType(),
170
-                   'resolve' => function ($value, $args, ResolveInfo $info) {
171
-                       return $this->_counter += $args['amount'];
172
-                   },
173
-                   'args'    => [
174
-                       'amount' => [
175
-                           'type'    => new IntType(),
176
-                           'default' => 1
177
-                       ]
178
-                   ]
179
-               ]))->addField(new Field([
167
+                ->addField(new Field([
168
+                    'name'    => 'increaseCounter',
169
+                    'type'    => new IntType(),
170
+                    'resolve' => function ($value, $args, ResolveInfo $info) {
171
+                        return $this->_counter += $args['amount'];
172
+                    },
173
+                    'args'    => [
174
+                        'amount' => [
175
+                            'type'    => new IntType(),
176
+                            'default' => 1
177
+                        ]
178
+                    ]
179
+                ]))->addField(new Field([
180 180
                 'name'    => 'invalidResolveTypeMutation',
181 181
                 'type'    => new NonNullType(new IntType()),
182 182
                 'resolve' => function () {
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
                 'fields' => [
94 94
                     'list' => [
95 95
                         'type'    => new ListType(new StringType()),
96
-                        'resolve' => function () {
96
+                        'resolve' => function() {
97 97
                             return null;
98 98
                         }
99 99
                     ]
100 100
                 ]
101 101
             ])
102 102
         ]));
103
-        $data      = $processor->processPayload(' { list }')->getResponseData();
103
+        $data = $processor->processPayload(' { list }')->getResponseData();
104 104
         $this->assertEquals(['data' => ['list' => null]], $data);
105 105
     }
106 106
 
@@ -113,20 +113,20 @@  discard block
 block discarded – undo
113 113
                 'fields' => [
114 114
                     'list' => [
115 115
                         'type'    => new ListType(new StringType()),
116
-                        'resolve' => function () {
116
+                        'resolve' => function() {
117 117
                             return null;
118 118
                         }
119 119
                     ]
120 120
                 ]
121 121
             ])
122 122
         ]));
123
-        $data      = $processor->processPayload(' { __schema { subscriptionType { name } } }')->getResponseData();
123
+        $data = $processor->processPayload(' { __schema { subscriptionType { name } } }')->getResponseData();
124 124
         $this->assertEquals(['data' => ['__schema' => ['subscriptionType' => null]]], $data);
125 125
     }
126 126
 
127 127
     public function testSchemaOperations()
128 128
     {
129
-        $schema    = new Schema([
129
+        $schema = new Schema([
130 130
             'query' => new ObjectType([
131 131
                 'name'   => 'RootQuery',
132 132
                 'fields' => [
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
                                     'args'    => [
140 140
                                         'shorten' => new BooleanType()
141 141
                                     ],
142
-                                    'resolve' => function ($value, $args) {
142
+                                    'resolve' => function($value, $args) {
143 143
                                         return empty($args['shorten']) ? $value : $value;
144 144
                                     }
145 145
                                 ],
146 146
                                 'id_alias'  => [
147 147
                                     'type'    => new IdType(),
148
-                                    'resolve' => function ($value) {
148
+                                    'resolve' => function($value) {
149 149
                                         return $value['id'];
150 150
                                     }
151 151
                                 ],
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                                 'code'      => new StringType(),
154 154
                             ]
155 155
                         ]),
156
-                        'resolve' => function ($value, $args) {
156
+                        'resolve' => function($value, $args) {
157 157
                             $data = ['id' => '123', 'firstName' => 'John', 'code' => '007'];
158 158
                             if (!empty($args['upper'])) {
159 159
                                 foreach ($data as $key => $value) {
@@ -172,19 +172,19 @@  discard block
 block discarded – undo
172 172
                     ],
173 173
                     'randomUser'        => [
174 174
                         'type'    => new TestObjectType(),
175
-                        'resolve' => function () {
175
+                        'resolve' => function() {
176 176
                             return ['invalidField' => 'John'];
177 177
                         }
178 178
                     ],
179 179
                     'invalidValueQuery' => [
180 180
                         'type'    => new TestObjectType(),
181
-                        'resolve' => function () {
181
+                        'resolve' => function() {
182 182
                             return 'stringValue';
183 183
                         }
184 184
                     ],
185 185
                     'labels'            => [
186 186
                         'type'    => new ListType(new StringType()),
187
-                        'resolve' => function () {
187
+                        'resolve' => function() {
188 188
                             return ['one', 'two'];
189 189
                         }
190 190
                     ]
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                ->addField(new Field([
216 216
                    'name'    => 'increaseCounter',
217 217
                    'type'    => new IntType(),
218
-                   'resolve' => function ($value, $args, ResolveInfo $info) {
218
+                   'resolve' => function($value, $args, ResolveInfo $info) {
219 219
                        return $this->_counter += $args['amount'];
220 220
                    },
221 221
                    'args'    => [
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
                ]))->addField(new Field([
228 228
                 'name'    => 'invalidResolveTypeMutation',
229 229
                 'type'    => new NonNullType(new IntType()),
230
-                'resolve' => function () {
230
+                'resolve' => function() {
231 231
                     return null;
232 232
                 }
233 233
             ]))->addField(new Field([
234 234
                 'name'    => 'interfacedMutation',
235 235
                 'type'    => new TestInterfaceType(),
236
-                'resolve' => function () {
236
+                'resolve' => function() {
237 237
                     return ['name' => 'John'];
238 238
                 }
239 239
             ]));
@@ -279,43 +279,43 @@  discard block
 block discarded – undo
279 279
                 'fields' => [
280 280
                     'listQuery'                 => [
281 281
                         'type'    => new ListType(new TestEnumType()),
282
-                        'resolve' => function () {
282
+                        'resolve' => function() {
283 283
                             return 'invalid list';
284 284
                         }
285 285
                     ],
286 286
                     'listEnumQuery'             => [
287 287
                         'type'    => new ListType(new TestEnumType()),
288
-                        'resolve' => function () {
288
+                        'resolve' => function() {
289 289
                             return ['invalid enum'];
290 290
                         }
291 291
                     ],
292 292
                     'invalidEnumQuery'          => [
293 293
                         'type'    => new TestEnumType(),
294
-                        'resolve' => function () {
294
+                        'resolve' => function() {
295 295
                             return 'invalid enum';
296 296
                         }
297 297
                     ],
298 298
                     'enumQuery'                 => [
299 299
                         'type'    => new TestEnumType(),
300
-                        'resolve' => function () {
300
+                        'resolve' => function() {
301 301
                             return 1;
302 302
                         }
303 303
                     ],
304 304
                     'invalidNonNullQuery'       => [
305 305
                         'type'    => new NonNullType(new IntType()),
306
-                        'resolve' => function () {
306
+                        'resolve' => function() {
307 307
                             return null;
308 308
                         }
309 309
                     ],
310 310
                     'invalidNonNullInsideQuery' => [
311 311
                         'type'    => new NonNullType(new IntType()),
312
-                        'resolve' => function () {
312
+                        'resolve' => function() {
313 313
                             return 'hello';
314 314
                         }
315 315
                     ],
316 316
                     'objectQuery'               => [
317 317
                         'type'    => new TestObjectType(),
318
-                        'resolve' => function () {
318
+                        'resolve' => function() {
319 319
                             return ['name' => 'John'];
320 320
                         }
321 321
                     ],
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
                                 'enum'   => new TestEnumType(),
328 328
                             ],
329 329
                         ]),
330
-                        'resolve' => function () {
330
+                        'resolve' => function() {
331 331
                             return [
332 332
                                 'object' => [
333 333
                                     'name' => 'John'
@@ -396,10 +396,10 @@  discard block
 block discarded – undo
396 396
             ]
397 397
         ]);
398 398
 
399
-        $union        = new UnionType([
399
+        $union = new UnionType([
400 400
             'name'        => 'TestUnion',
401 401
             'types'       => [$object1, $object2],
402
-            'resolveType' => function ($object) use ($object1, $object2) {
402
+            'resolveType' => function($object) use ($object1, $object2) {
403 403
                 if (isset($object['id'])) {
404 404
                     return $object1;
405 405
                 }
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
         $invalidUnion = new UnionType([
411 411
             'name'        => 'TestUnion',
412 412
             'types'       => [$object1, $object2],
413
-            'resolveType' => function ($object) use ($object3) {
413
+            'resolveType' => function($object) use ($object3) {
414 414
                 return $object3;
415 415
             }
416 416
         ]);
417
-        $processor    = new Processor(new Schema([
417
+        $processor = new Processor(new Schema([
418 418
             'query' => new ObjectType([
419 419
                 'name'   => 'RootQuery',
420 420
                 'fields' => [
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
                         'args'    => [
424 424
                             'type' => ['type' => 'string']
425 425
                         ],
426
-                        'resolve' => function ($value, $args) {
426
+                        'resolve' => function($value, $args) {
427 427
                             if ($args['type'] == 'object1') {
428 428
                                 return [
429 429
                                     'id' => 43
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
                     ],
438 438
                     'invalidUnion' => [
439 439
                         'type'    => $invalidUnion,
440
-                        'resolve' => function () {
440
+                        'resolve' => function() {
441 441
                             return ['name' => 'name resolved'];
442 442
                         }
443 443
                     ],
Please login to merge, or discard this patch.
Tests/Schema/IntrospectionTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             'description'       => 'latest description',
136 136
             'deprecationReason' => 'for test',
137 137
             'isDeprecated'      => true,
138
-            'resolve'           => function () {
138
+            'resolve'           => function() {
139 139
                 return [
140 140
                     'id'   => 1,
141 141
                     'name' => 'Alex'
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
                                 ['name' => 'String', 'fields' => null],
198 198
                                 ['name' => '__Schema', 'fields' => [['name' => 'queryType'], ['name' => 'mutationType'], ['name' => 'subscriptionType'], ['name' => 'types'], ['name' => 'directives']]],
199 199
                                 ['name' => '__Type', 'fields' => [['name' => 'name'], ['name' => 'kind'], ['name' => 'description'], ['name' => 'ofType'], ['name' => 'inputFields'], ['name' => 'enumValues'], ['name' => 'fields'], ['name' => 'interfaces'], ['name' => 'possibleTypes']]],
200
-                                ['name' => '__InputValue', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'type'], ['name' => 'defaultValue'],]],
201
-                                ['name' => '__EnumValue', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'deprecationReason'], ['name' => 'isDeprecated'],]],
200
+                                ['name' => '__InputValue', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'type'], ['name' => 'defaultValue'], ]],
201
+                                ['name' => '__EnumValue', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'deprecationReason'], ['name' => 'isDeprecated'], ]],
202 202
                                 ['name' => 'Boolean', 'fields' => null],
203 203
                                 ['name' => '__Field', 'fields' => [['name' => 'name'], ['name' => 'description'], ['name' => 'isDeprecated'], ['name' => 'deprecationReason'], ['name' => 'type'], ['name' => 'args']]],
204 204
                                 ['name' => '__Subscription', 'fields' => [['name' => 'name']]],
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
                 'id'   => ['type' => new IntType()],
288 288
                 'name' => ['type' => new IntType()],
289 289
             ],
290
-            'resolveType' => function ($type) {
290
+            'resolveType' => function($type) {
291 291
 
292 292
             }
293 293
         ]);
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
         $unionType = new UnionType([
316 316
             'name'        => 'UnionType',
317 317
             'types'       => [$object1, $object2],
318
-            'resolveType' => function () {
318
+            'resolveType' => function() {
319 319
 
320 320
             }
321 321
         ]);
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
             'args'    => [
327 327
                 'id' => ['type' => TypeMap::TYPE_INT]
328 328
             ],
329
-            'resolve' => function () {
329
+            'resolve' => function() {
330 330
                 return [
331 331
                     'id'   => 1,
332 332
                     'name' => 'Alex'
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
                     ]
353 353
                 ])
354 354
             ],
355
-            'resolve' => function () {
355
+            'resolve' => function() {
356 356
                 return null;
357 357
             }
358 358
         ]));
Please login to merge, or discard this patch.
Tests/Schema/SchemaTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
             'fields' => [
27 27
                 'currentTime' => [
28 28
                     'type'    => new StringType(),
29
-                    'resolve' => function ($value, $args, $type) {
29
+                    'resolve' => function($value, $args, $type) {
30 30
                         return 'May 5, 9:00am';
31 31
                     },
32 32
                     'args'    => [
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
         $this->assertEquals(1, count($schema->getMutationType()->getFields()));
57 57
 
58
-        $schema->addMutationField('changeUser', ['type' => new TestObjectType(), 'resolve' => function () { }]);
58
+        $schema->addMutationField('changeUser', ['type' => new TestObjectType(), 'resolve' => function() { }]);
59 59
         $this->assertEquals(2, count($schema->getMutationType()->getFields()));
60 60
 
61 61
     }
Please login to merge, or discard this patch.