Passed
Pull Request — master (#1)
by Max
05:13
created
tests/Type/ValidatedFieldDefinition/ListOfScalarValidationTest.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
             null,
94 94
             [
95 95
                 'phoneNumbers' => [
96
-                	[
97
-	                    '123-4567',
98
-	                    'xxx456-7890xxx'
99
-		            ]
96
+                    [
97
+                        '123-4567',
98
+                        'xxx456-7890xxx'
99
+                    ]
100 100
                 ],
101 101
             ]
102 102
         );
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
                         'phoneNumbers' =>
110 110
                             [
111 111
                                 'suberrors' =>
112
-	                                [
113
-	                                    'path' => [0,1],
114
-	                                    'code' => 'invalidPhoneNumber',
115
-	                                ]
112
+                                    [
113
+                                        'path' => [0,1],
114
+                                        'code' => 'invalidPhoneNumber',
115
+                                    ]
116 116
                             ],
117 117
                     ],
118 118
                 'result' => null,
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
         static::assertFalse($res->data['setPhoneNumbers']['valid']);
125 125
     }
126 126
 
127
-	public function testItemsValidationOnSelfFail()
128
-	{
129
-		$res = GraphQL::executeQuery(
130
-			$this->schema,
131
-			Utils::nowdoc('
127
+    public function testItemsValidationOnSelfFail()
128
+    {
129
+        $res = GraphQL::executeQuery(
130
+            $this->schema,
131
+            Utils::nowdoc('
132 132
 				mutation SetPhoneNumbers(
133 133
 						$phoneNumbers: [[String]]
134 134
 					) {
@@ -148,34 +148,34 @@  discard block
 block discarded – undo
148 148
 						}
149 149
 					}
150 150
 			'),
151
-			[],
152
-			null,
153
-			[
154
-				'phoneNumbers' => [
155
-				],
156
-			]
157
-		);
158
-
159
-		static::assertEquals(
160
-			array (
161
-				'valid' => false,
162
-				'suberrors' =>
163
-					array (
164
-						'phoneNumbers' =>
165
-							array (
166
-								'code' => 'atLeastOneList',
167
-								'msg' => 'You must submit at least one list of numbers',
168
-								'suberrors' => NULL,
169
-							),
170
-					),
171
-				'result' => NULL,
172
-			),
173
-			$res->data['setPhoneNumbers']
174
-		);
175
-
176
-		static::assertEmpty($res->errors);
177
-		static::assertFalse($res->data['setPhoneNumbers']['valid']);
178
-	}
151
+            [],
152
+            null,
153
+            [
154
+                'phoneNumbers' => [
155
+                ],
156
+            ]
157
+        );
158
+
159
+        static::assertEquals(
160
+            array (
161
+                'valid' => false,
162
+                'suberrors' =>
163
+                    array (
164
+                        'phoneNumbers' =>
165
+                            array (
166
+                                'code' => 'atLeastOneList',
167
+                                'msg' => 'You must submit at least one list of numbers',
168
+                                'suberrors' => NULL,
169
+                            ),
170
+                    ),
171
+                'result' => NULL,
172
+            ),
173
+            $res->data['setPhoneNumbers']
174
+        );
175
+
176
+        static::assertEmpty($res->errors);
177
+        static::assertFalse($res->data['setPhoneNumbers']['valid']);
178
+    }
179 179
 
180 180
     public function testListOfValidationFail()
181 181
     {
@@ -205,39 +205,39 @@  discard block
 block discarded – undo
205 205
             null,
206 206
             [
207 207
                 'phoneNumbers' => [
208
-                	[],
209
-                	[
210
-	                    '123-4567',
211
-	                    'xxx-7890',
212
-	                    '321-1234'
213
-		            ]
208
+                    [],
209
+                    [
210
+                        '123-4567',
211
+                        'xxx-7890',
212
+                        '321-1234'
213
+                    ]
214 214
                 ],
215 215
             ]
216 216
         );
217 217
 
218 218
         static::assertEmpty($res->errors);
219 219
         static::assertEquals(
220
-	        array (
221
-		        'valid' => false,
222
-		        'suberrors' =>
223
-			        array (
224
-				        'phoneNumbers' =>
225
-					        array (
226
-						        'code' => NULL,
227
-						        'msg' => NULL,
228
-						        'suberrors' =>
229
-							        array (
230
-								        'path' =>
231
-									        array (
232
-										        0 => 1,
233
-										        1 => 1,
234
-									        ),
235
-								        'code' => 'invalidPhoneNumber',
236
-							        ),
237
-					        ),
238
-			        ),
239
-		        'result' => NULL,
240
-	        ),
220
+            array (
221
+                'valid' => false,
222
+                'suberrors' =>
223
+                    array (
224
+                        'phoneNumbers' =>
225
+                            array (
226
+                                'code' => NULL,
227
+                                'msg' => NULL,
228
+                                'suberrors' =>
229
+                                    array (
230
+                                        'path' =>
231
+                                            array (
232
+                                                0 => 1,
233
+                                                1 => 1,
234
+                                            ),
235
+                                        'code' => 'invalidPhoneNumber',
236
+                                    ),
237
+                            ),
238
+                    ),
239
+                'result' => NULL,
240
+            ),
241 241
             $res->data['setPhoneNumbers']
242 242
         );
243 243
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
             'query' => $this->query,
32 32
             'mutation' => new ObjectType([
33 33
                 'name' => 'Mutation',
34
-                'fields' => static function () {
34
+                'fields' => static function() {
35 35
                     return [
36 36
                         'setPhoneNumbers' => new ValidatedFieldDefinition([
37 37
                             'name' => 'setPhoneNumbers',
@@ -40,20 +40,20 @@  discard block
 block discarded – undo
40 40
                                 'phoneNumbers' => [
41 41
                                     'type' => Type::listOf(Type::listOf(Type::string())),
42 42
                                     'errorCodes' => ['atLeastOneList'],
43
-                                    'validate' => static function (array $phoneNumberLists) {
43
+                                    'validate' => static function(array $phoneNumberLists) {
44 44
                                         if (count($phoneNumberLists) < 1) {
45 45
                                             return ['atLeastOneList', 'You must submit at least one list of numbers'];
46 46
                                         }
47 47
                                         return 0;
48 48
                                     },
49 49
                                     'suberrorCodes' => ['invalidPhoneNumber'],
50
-                                    'validateItem' => static function ($phoneNumber) {
50
+                                    'validateItem' => static function($phoneNumber) {
51 51
                                         $res = preg_match('/^[0-9\-]+$/', $phoneNumber) === 1;
52
-                                        return ! $res ? ['invalidPhoneNumber', 'That does not seem to be a valid phone number'] : 0;
52
+                                        return !$res ? ['invalidPhoneNumber', 'That does not seem to be a valid phone number'] : 0;
53 53
                                     },
54 54
                                 ],
55 55
                             ],
56
-                            'resolve' => static function (array $phoneNumbers, $args) : bool {
56
+                            'resolve' => static function(array $phoneNumbers, $args) : bool {
57 57
                                 // ...
58 58
                                 // stash them somewhere
59 59
                                 // ...
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
                             [
111 111
                                 'suberrors' =>
112 112
 	                                [
113
-	                                    'path' => [0,1],
113
+	                                    'path' => [0, 1],
114 114
 	                                    'code' => 'invalidPhoneNumber',
115 115
 	                                ]
116 116
                             ],
@@ -157,12 +157,12 @@  discard block
 block discarded – undo
157 157
 		);
158 158
 
159 159
 		static::assertEquals(
160
-			array (
160
+			array(
161 161
 				'valid' => false,
162 162
 				'suberrors' =>
163
-					array (
163
+					array(
164 164
 						'phoneNumbers' =>
165
-							array (
165
+							array(
166 166
 								'code' => 'atLeastOneList',
167 167
 								'msg' => 'You must submit at least one list of numbers',
168 168
 								'suberrors' => NULL,
@@ -217,18 +217,18 @@  discard block
 block discarded – undo
217 217
 
218 218
         static::assertEmpty($res->errors);
219 219
         static::assertEquals(
220
-	        array (
220
+	        array(
221 221
 		        'valid' => false,
222 222
 		        'suberrors' =>
223
-			        array (
223
+			        array(
224 224
 				        'phoneNumbers' =>
225
-					        array (
225
+					        array(
226 226
 						        'code' => NULL,
227 227
 						        'msg' => NULL,
228 228
 						        'suberrors' =>
229
-							        array (
229
+							        array(
230 230
 								        'path' =>
231
-									        array (
231
+									        array(
232 232
 										        0 => 1,
233 233
 										        1 => 1,
234 234
 									        ),
Please login to merge, or discard this patch.
tests/Type/ValidatedFieldDefinition/InputObjectValidationTest.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -99,18 +99,18 @@  discard block
 block discarded – undo
99 99
                             'args' => [
100 100
                                 'bookAttributes' => [
101 101
                                     'type' => $this->bookAttributesInputType,
102
-	                                'errorCodes' => [
103
-										'titleOrIdRequired'
104
-	                                ],
105
-	                                'validate' => static function(?array $bookAttributes) {
106
-                        	            if(is_null($bookAttributes)) {
107
-                        	                return 0;
108
-	                                    }
102
+                                    'errorCodes' => [
103
+                                        'titleOrIdRequired'
104
+                                    ],
105
+                                    'validate' => static function(?array $bookAttributes) {
106
+                                        if(is_null($bookAttributes)) {
107
+                                            return 0;
108
+                                        }
109 109
                         	            
110
-                        	            return (isset($bookAttributes['title']) || isset($bookAttributes['author'])) ? 0 : [
111
-                        	            	'titleOrIdRequired', 'You must supply at least one of title or author'
112
-	                                    ];
113
-	                                }
110
+                                        return (isset($bookAttributes['title']) || isset($bookAttributes['author'])) ? 0 : [
111
+                                            'titleOrIdRequired', 'You must supply at least one of title or author'
112
+                                        ];
113
+                                    }
114 114
                                 ],
115 115
                             ],
116 116
                             'resolve' => static function ($value, $args) : bool {
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
         static::assertFalse($res->data['updateBook']['valid']);
198 198
     }
199 199
 
200
-	public function testValidationInputObjectSelfFail()
201
-	{
202
-		$res = GraphQL::executeQuery(
203
-			$this->schema,
204
-			Utils::nowdoc('
200
+    public function testValidationInputObjectSelfFail()
201
+    {
202
+        $res = GraphQL::executeQuery(
203
+            $this->schema,
204
+            Utils::nowdoc('
205 205
 				mutation UpdateBook(
206 206
 						$bookAttributes: BookAttributes
207 207
 					) {
@@ -229,35 +229,35 @@  discard block
 block discarded – undo
229 229
 					}
230 230
 				}
231 231
 			'),
232
-			[],
233
-			null,
234
-			[
235
-				'bookAttributes' => [
236
-					'title' => null,
237
-					'author' => null,
238
-				],
239
-			]
240
-		);
232
+            [],
233
+            null,
234
+            [
235
+                'bookAttributes' => [
236
+                    'title' => null,
237
+                    'author' => null,
238
+                ],
239
+            ]
240
+        );
241 241
 
242
-		static::assertEquals(
243
-			array (
244
-				'valid' => false,
245
-				'suberrors' =>
246
-					array (
247
-						'bookAttributes' =>
248
-							array (
249
-								'code' => 'titleOrIdRequired',
250
-								'msg' => 'You must supply at least one of title or author',
251
-								'suberrors' => NULL,
252
-							),
253
-					),
254
-				'result' => NULL,
255
-			),
256
-			$res->data['updateBook']
257
-		);
242
+        static::assertEquals(
243
+            array (
244
+                'valid' => false,
245
+                'suberrors' =>
246
+                    array (
247
+                        'bookAttributes' =>
248
+                            array (
249
+                                'code' => 'titleOrIdRequired',
250
+                                'msg' => 'You must supply at least one of title or author',
251
+                                'suberrors' => NULL,
252
+                            ),
253
+                    ),
254
+                'result' => NULL,
255
+            ),
256
+            $res->data['updateBook']
257
+        );
258 258
 
259
-		static::assertFalse($res->data['updateBook']['valid']);
260
-	}
259
+        static::assertFalse($res->data['updateBook']['valid']);
260
+    }
261 261
 
262 262
     public function testValidationSuccess()
263 263
     {
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
 
352 352
         static::assertEmpty($res->errors);
353 353
         static::assertEquals(
354
-	        array (
355
-		        'valid' => true,
356
-		        'suberrors' => NULL,
357
-		        'result' => true,
358
-	        ),
354
+            array (
355
+                'valid' => true,
356
+                'suberrors' => NULL,
357
+                'result' => true,
358
+            ),
359 359
             $res->data['updateBook']
360 360
         );
361 361
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                 'title' => [
62 62
                     'type' => Type::string(),
63 63
                     'description' => 'Enter a book title, no more than 10 characters in length',
64
-                    'validate' => static function (string $title) {
64
+                    'validate' => static function(string $title) {
65 65
                         if (strlen($title) > 10) {
66 66
                             return [1, 'book title must be less than 10 chaacters'];
67 67
                         }
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
                         'unknownAuthor',
76 76
                         'authorDeceased',
77 77
                     ],
78
-                    'validate' => function (string $authorId) {
79
-                        if (! isset($this->data['people'][$authorId])) {
78
+                    'validate' => function(string $authorId) {
79
+                        if (!isset($this->data['people'][$authorId])) {
80 80
                             return ['unknownAuthor', 'We have no record of that author'];
81 81
                         }
82 82
                         return 0;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             'query' => $this->query,
92 92
             'mutation' => new ObjectType([
93 93
                 'name' => 'Mutation',
94
-                'fields' => function () {
94
+                'fields' => function() {
95 95
                     return [
96 96
                         'updateBook' => new ValidatedFieldDefinition([
97 97
                             'name' => 'updateBook',
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 										'titleOrIdRequired'
104 104
 	                                ],
105 105
 	                                'validate' => static function(?array $bookAttributes) {
106
-                        	            if(is_null($bookAttributes)) {
106
+                        	            if (is_null($bookAttributes)) {
107 107
                         	                return 0;
108 108
 	                                    }
109 109
                         	            
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	                                }
114 114
                                 ],
115 115
                             ],
116
-                            'resolve' => static function ($value, $args) : bool {
116
+                            'resolve' => static function($value, $args) : bool {
117 117
                                 // ...
118 118
                                 // do update
119 119
                                 // ...
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
 		);
241 241
 
242 242
 		static::assertEquals(
243
-			array (
243
+			array(
244 244
 				'valid' => false,
245 245
 				'suberrors' =>
246
-					array (
246
+					array(
247 247
 						'bookAttributes' =>
248
-							array (
248
+							array(
249 249
 								'code' => 'titleOrIdRequired',
250 250
 								'msg' => 'You must supply at least one of title or author',
251 251
 								'suberrors' => NULL,
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 
352 352
         static::assertEmpty($res->errors);
353 353
         static::assertEquals(
354
-	        array (
354
+	        array(
355 355
 		        'valid' => true,
356 356
 		        'suberrors' => NULL,
357 357
 		        'result' => true,
Please login to merge, or discard this patch.
tests/Type/ValidatedFieldDefinition/BasicTest.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -9,46 +9,46 @@
 block discarded – undo
9 9
 
10 10
 final class BasicTest extends TestCase
11 11
 {
12
-	public function testInferName()
13
-	{
14
-		$def = new NamelessDef([
15
-			'type' => Type::boolean(),
16
-			'args' => [
17
-				'bookId' => [
18
-					'type' => Type::id(),
19
-					'errorCodes' => ['bookNotFound'],
20
-					'validate' => function ($bookId) {
21
-						return 0;
22
-					},
23
-				],
24
-			],
25
-			'resolve' => static function ($value, $args) : bool {
26
-				return true;
27
-			},
28
-		]);
12
+    public function testInferName()
13
+    {
14
+        $def = new NamelessDef([
15
+            'type' => Type::boolean(),
16
+            'args' => [
17
+                'bookId' => [
18
+                    'type' => Type::id(),
19
+                    'errorCodes' => ['bookNotFound'],
20
+                    'validate' => function ($bookId) {
21
+                        return 0;
22
+                    },
23
+                ],
24
+            ],
25
+            'resolve' => static function ($value, $args) : bool {
26
+                return true;
27
+            },
28
+        ]);
29 29
 
30
-		static::assertEquals("namelessDef", $def->name);
31
-	}
30
+        static::assertEquals("namelessDef", $def->name);
31
+    }
32 32
 
33
-	public function testInferNameNameAlreadyExists()
34
-	{
35
-		$def = new NamelessDef([
36
-			'name' => "FooDef",
37
-			'type' => Type::boolean(),
38
-			'args' => [
39
-				'bookId' => [
40
-					'type' => Type::id(),
41
-					'errorCodes' => ['bookNotFound'],
42
-					'validate' => function ($bookId) {
43
-						return 0;
44
-					},
45
-				],
46
-			],
47
-			'resolve' => static function ($value, $args) : bool {
48
-				return true;
49
-			},
50
-		]);
33
+    public function testInferNameNameAlreadyExists()
34
+    {
35
+        $def = new NamelessDef([
36
+            'name' => "FooDef",
37
+            'type' => Type::boolean(),
38
+            'args' => [
39
+                'bookId' => [
40
+                    'type' => Type::id(),
41
+                    'errorCodes' => ['bookNotFound'],
42
+                    'validate' => function ($bookId) {
43
+                        return 0;
44
+                    },
45
+                ],
46
+            ],
47
+            'resolve' => static function ($value, $args) : bool {
48
+                return true;
49
+            },
50
+        ]);
51 51
 
52
-		static::assertEquals("FooDef", $def->name);
53
-	}
52
+        static::assertEquals("FooDef", $def->name);
53
+    }
54 54
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 				'bookId' => [
18 18
 					'type' => Type::id(),
19 19
 					'errorCodes' => ['bookNotFound'],
20
-					'validate' => function ($bookId) {
20
+					'validate' => function($bookId) {
21 21
 						return 0;
22 22
 					},
23 23
 				],
24 24
 			],
25
-			'resolve' => static function ($value, $args) : bool {
25
+			'resolve' => static function($value, $args) : bool {
26 26
 				return true;
27 27
 			},
28 28
 		]);
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 				'bookId' => [
40 40
 					'type' => Type::id(),
41 41
 					'errorCodes' => ['bookNotFound'],
42
-					'validate' => function ($bookId) {
42
+					'validate' => function($bookId) {
43 43
 						return 0;
44 44
 					},
45 45
 				],
46 46
 			],
47
-			'resolve' => static function ($value, $args) : bool {
47
+			'resolve' => static function($value, $args) : bool {
48 48
 				return true;
49 49
 			},
50 50
 		]);
Please login to merge, or discard this patch.
tests/Type/UserErrorsType/BasicTest.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@
 block discarded – undo
33 33
     }
34 34
 
35 35
     public function testNoType() {
36
-	    $this->expectExceptionMessage("You must specify a type for your field");
37
-	    UserErrorsType::create([
38
-		    'validate' => static function ($value) {
39
-		    }
40
-	    ], ['upsertSku']);
36
+        $this->expectExceptionMessage("You must specify a type for your field");
37
+        UserErrorsType::create([
38
+            'validate' => static function ($value) {
39
+            }
40
+        ], ['upsertSku']);
41 41
     }
42 42
 
43 43
     public function testValidationWithNoErrorCodes()
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     public function testNoType() {
36 36
 	    $this->expectExceptionMessage("You must specify a type for your field");
37 37
 	    UserErrorsType::create([
38
-		    'validate' => static function ($value) {
38
+		    'validate' => static function($value) {
39 39
 		    }
40 40
 	    ], ['upsertSku']);
41 41
     }
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function testValidationWithNoErrorCodes()
44 44
     {
45 45
         $type = UserErrorsType::create([
46
-            'validate' => static function ($value) {
46
+            'validate' => static function($value) {
47 47
             },
48 48
             'type' => Type::id(),
49 49
         ], ['upsertSku']);
Please login to merge, or discard this patch.
src/Type/Definition/UserErrorsType.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -23,40 +23,40 @@
 block discarded – undo
23 23
     {
24 24
         $finalFields = $config['fields'] ?? [];
25 25
 
26
-	    if (!isset($config['type'])) {
27
-		    throw new \Exception('You must specify a type for your field');
28
-	    }
26
+        if (!isset($config['type'])) {
27
+            throw new \Exception('You must specify a type for your field');
28
+        }
29 29
 
30 30
         GraphQL\Utils\Utils::invariant($config['type'] instanceof Type, 'Must provide type.');
31 31
 
32 32
         if (isset($config['errorCodes'])) {
33
-        	if(isset($config['validate'])) {
34
-		        /** code property */
35
-		        $finalFields['code'] = [
36
-			        'type' => $this->_set(new EnumType([
37
-				        'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode',
38
-				        'description' => 'Error code',
39
-				        'values' => $config['errorCodes'],
40
-			        ]), $config),
41
-			        'description' => 'An error code',
42
-			        'resolve' => static function ($value) {
43
-				        return $value['error'][0] ?? null;
44
-			        },
45
-		        ];
46
-
47
-		        /**
48
-		         * msg property
49
-		         */
50
-		        $finalFields['msg'] = [
51
-			        'type' => Type::string(),
52
-			        'description' => 'A natural language description of the issue',
53
-			        'resolve' => static function ($value) {
54
-				        return $value['error'][1] ?? null;
55
-			        },
56
-		        ];
57
-	        } else {
58
-        		throw new \Exception("If you specify errorCodes, you must also provide a validate callback");
59
-	        }
33
+            if(isset($config['validate'])) {
34
+                /** code property */
35
+                $finalFields['code'] = [
36
+                    'type' => $this->_set(new EnumType([
37
+                        'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode',
38
+                        'description' => 'Error code',
39
+                        'values' => $config['errorCodes'],
40
+                    ]), $config),
41
+                    'description' => 'An error code',
42
+                    'resolve' => static function ($value) {
43
+                        return $value['error'][0] ?? null;
44
+                    },
45
+                ];
46
+
47
+                /**
48
+                 * msg property
49
+                 */
50
+                $finalFields['msg'] = [
51
+                    'type' => Type::string(),
52
+                    'description' => 'A natural language description of the issue',
53
+                    'resolve' => static function ($value) {
54
+                        return $value['error'][1] ?? null;
55
+                    },
56
+                ];
57
+            } else {
58
+                throw new \Exception("If you specify errorCodes, you must also provide a validate callback");
59
+            }
60 60
         }
61 61
 
62 62
         $type = $config['type'];
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         GraphQL\Utils\Utils::invariant($config['type'] instanceof Type, 'Must provide type.');
31 31
 
32 32
         if (isset($config['errorCodes'])) {
33
-        	if(isset($config['validate'])) {
33
+        	if (isset($config['validate'])) {
34 34
 		        /** code property */
35 35
 		        $finalFields['code'] = [
36 36
 			        'type' => $this->_set(new EnumType([
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 				        'values' => $config['errorCodes'],
40 40
 			        ]), $config),
41 41
 			        'description' => 'An error code',
42
-			        'resolve' => static function ($value) {
42
+			        'resolve' => static function($value) {
43 43
 				        return $value['error'][0] ?? null;
44 44
 			        },
45 45
 		        ];
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		        $finalFields['msg'] = [
51 51
 			        'type' => Type::string(),
52 52
 			        'description' => 'A natural language description of the issue',
53
-			        'resolve' => static function ($value) {
53
+			        'resolve' => static function($value) {
54 54
 				        return $value['error'][1] ?? null;
55 55
 			        },
56 56
 		        ];
@@ -64,18 +64,18 @@  discard block
 block discarded – undo
64 64
             $fields = [];
65 65
             foreach ($type->getFields() as $key => $field) {
66 66
                 $newType = static::create(
67
-                    $field->config + ['typeSetter' => $config['typeSetter'] ?? null],
67
+                    $field->config+['typeSetter' => $config['typeSetter'] ?? null],
68 68
                     array_merge($path, [$key])
69 69
                 );
70 70
 
71
-                if (! $newType) {
71
+                if (!$newType) {
72 72
                     continue;
73 73
                 }
74 74
 
75 75
                 $fields[$key] = [
76 76
                     'description' => 'Error for ' . $key,
77 77
                     'type' => $newType,
78
-                    'resolve' => static function ($value) use ($key) {
78
+                    'resolve' => static function($value) use ($key) {
79 79
                         return $value[$key] ?? null;
80 80
                     },
81 81
                 ];
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
                         'fields' => $fields,
93 93
                     ]), $config),
94 94
                     'description' => 'Suberrors for ' . ucfirst($path[count($path)-1]),
95
-                    'resolve' => static function (array $value) {
95
+                    'resolve' => static function(array $value) {
96 96
                         return $value['suberrors'] ?? null;
97 97
                     },
98 98
                 ];
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 $finalFields['suberrors'] = [
117 117
                     'description' => 'Suberrors for the list of ' . $type->ofType . ' items',
118 118
                     'type' => $newType,
119
-                    'resolve' => static function ($value) {
119
+                    'resolve' => static function($value) {
120 120
                         return $value['suberrors'] ?? null;
121 121
                     },
122 122
                 ];
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             $finalFields['path'] = [
131 131
                 'type' => Type::listOf(Type::int()),
132 132
                 'description' => 'A path describing this items\'s location in the nested array',
133
-                'resolve' => static function ($value) {
133
+                'resolve' => static function($value) {
134 134
                     return $value['path'];
135 135
                 },
136 136
             ];
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             $config['fields']['code'] = $config['fields']['code'] ?? [
168 168
                 'type' => Type::int(),
169 169
                 'description' => 'A numeric error code. 0 on success, non-zero on failure.',
170
-                'resolve' => static function ($value) {
170
+                'resolve' => static function($value) {
171 171
                     $error = $value['error'] ?? null;
172 172
                     switch (gettype($error)) {
173 173
                         case 'integer':
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
             $config['fields']['msg'] = $config['fields']['msg'] ?? [
181 181
                 'type' => Type::string(),
182 182
                 'description' => 'An error message.',
183
-                'resolve' => static function ($value) {
183
+                'resolve' => static function($value) {
184 184
                     $error = $value['error'] ?? null;
185 185
                     switch (gettype($error)) {
186 186
                         case 'integer':
Please login to merge, or discard this patch.