Passed
Pull Request — master (#1)
by Max
05:13
created
tests/Utils.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
         }
23 23
 
24 24
         // Toss out the first and last lines.
25
-        $lines = array_slice($lines, 1, count($lines) - 2);
25
+        $lines = array_slice($lines, 1, count($lines)-2);
26 26
 
27 27
         // take the tabs from the first line, and subtract them from all lines
28 28
         $matches = [];
Please login to merge, or discard this patch.
tests/Type/ErrorCodeTypeGenerationTest.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     {
20 20
         $types = [];
21 21
         new UserErrorsType([
22
-        	'validate' => static function($val) {},
22
+            'validate' => static function($val) {},
23 23
             'errorCodes' => [
24 24
                 'unknownUser',
25 25
                 'userIsMinor',
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 'name' => 'bookInput',
80 80
                 'fields' => [
81 81
                     'authorId' => [
82
-	                    'validate' => static function($authorId) {},
82
+                        'validate' => static function($authorId) {},
83 83
                         'errorCodes' => ['unknownAuthor'],
84 84
                         'type' => Type::id(),
85 85
                         'description' => 'An author Id',
Please login to merge, or discard this patch.
tests/Type/UserErrorsType/InputObjectTest.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function testFieldsWithErrorCodesButNoValidate()
47 47
     {
48
-	    $this->expectExceptionMessage("If you specify errorCodes, you must also provide a validate callback");
48
+        $this->expectExceptionMessage("If you specify errorCodes, you must also provide a validate callback");
49 49
 
50
-	    $type  = new UserErrorsType([
50
+        $type  = new UserErrorsType([
51 51
             'type' => new InputObjectType([
52 52
                 'name' => 'bookInput',
53 53
                 'fields' => [
@@ -61,25 +61,25 @@  discard block
 block discarded – undo
61 61
         ], ['updateBook']);
62 62
     }
63 63
 
64
-	public function testFieldsWithValidate()
65
-	{
66
-		$type  = new UserErrorsType([
67
-			'type' => new InputObjectType([
68
-				'name' => 'bookInput',
69
-				'fields' => [
70
-					'authorId' => [
71
-						'errorCodes' => ['unknownAuthor'],
72
-						'validate' => static function(int $authorId) {
64
+    public function testFieldsWithValidate()
65
+    {
66
+        $type  = new UserErrorsType([
67
+            'type' => new InputObjectType([
68
+                'name' => 'bookInput',
69
+                'fields' => [
70
+                    'authorId' => [
71
+                        'errorCodes' => ['unknownAuthor'],
72
+                        'validate' => static function(int $authorId) {
73 73
 
74
-						},
75
-						'type' => Type::id(),
76
-						'description' => 'An author Id',
77
-					],
78
-				],
79
-			])
80
-		], ['updateBook']);
74
+                        },
75
+                        'type' => Type::id(),
76
+                        'description' => 'An author Id',
77
+                    ],
78
+                ],
79
+            ])
80
+        ], ['updateBook']);
81 81
 
82
-		self::assertEquals(Utils::nowdoc('
82
+        self::assertEquals(Utils::nowdoc('
83 83
 			schema {
84 84
 			  query: UpdateBookError
85 85
 			}
@@ -111,5 +111,5 @@  discard block
 block discarded – undo
111 111
 			}
112 112
 
113 113
 		'), SchemaPrinter::doPrint(new Schema(['query' => $type])));
114
-	}
114
+    }
115 115
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 {
18 18
     public function testFieldsWithNoErrorCodes()
19 19
     {
20
-        $type  = new UserErrorsType([
20
+        $type = new UserErrorsType([
21 21
             'type' => new InputObjectType([
22 22
                 'name' => 'bookInput',
23 23
                 'fields' => [
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     {
48 48
 	    $this->expectExceptionMessage("If you specify errorCodes, you must also provide a validate callback");
49 49
 
50
-	    $type  = new UserErrorsType([
50
+	    $type = new UserErrorsType([
51 51
             'type' => new InputObjectType([
52 52
                 'name' => 'bookInput',
53 53
                 'fields' => [
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
 	public function testFieldsWithValidate()
65 65
 	{
66
-		$type  = new UserErrorsType([
66
+		$type = new UserErrorsType([
67 67
 			'type' => new InputObjectType([
68 68
 				'name' => 'bookInput',
69 69
 				'fields' => [
Please login to merge, or discard this patch.
tests/Type/UserErrorsType/ScalarTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
     {
38 38
         $type = new UserErrorsType([
39 39
             'errorCodes' => ['invalidColor'],
40
-            'validate' => static function ($value) {
40
+            'validate' => static function($value) {
41 41
                 return 0;
42 42
             },
43 43
             'type' => new IDType(['name' => 'Color']),
Please login to merge, or discard this patch.
tests/Type/ValidatedFieldDefinition/ListOfInputObjectValidationTest.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
                             'args' => [
101 101
                                 'bookAttributes' => [
102 102
                                     'type' => Type::listOf($this->bookAttributesInputType),
103
-	                                'validate' => static function($var) {
104
-                        	            $i = 5;
105
-	                                },
106
-	                                'validateItem' => static function($book) {
107
-                        	            $res = isset($book['author']) || isset($book['title']) ? 0: 1;
108
-                        	            return $res;
109
-	                                }
103
+                                    'validate' => static function($var) {
104
+                                        $i = 5;
105
+                                    },
106
+                                    'validateItem' => static function($book) {
107
+                                        $res = isset($book['author']) || isset($book['title']) ? 0: 1;
108
+                                        return $res;
109
+                                    }
110 110
                                 ],
111 111
                             ],
112 112
                             'resolve' => static function ($value) : bool {
@@ -166,30 +166,30 @@  discard block
 block discarded – undo
166 166
             ]
167 167
         );
168 168
 
169
-	    static::assertEmpty($res->errors);
169
+        static::assertEmpty($res->errors);
170 170
 
171 171
         static::assertEquals(
172
-	        array (
173
-		        'valid' => false,
174
-		        'result' => NULL,
175
-		        'suberrors' =>
176
-			        array (
177
-				        'bookAttributes' =>
178
-					        array (
179
-						        'code' => NULL,
180
-						        'msg' => NULL,
181
-						        'suberrors' =>
182
-							        array (
183
-								        'code' => 1,
184
-								        'msg' => '',
185
-								        'path' =>
186
-									        array (
187
-										        0 => 1,
188
-									        ),
189
-							        ),
190
-					        ),
191
-			        ),
192
-	        ),
172
+            array (
173
+                'valid' => false,
174
+                'result' => NULL,
175
+                'suberrors' =>
176
+                    array (
177
+                        'bookAttributes' =>
178
+                            array (
179
+                                'code' => NULL,
180
+                                'msg' => NULL,
181
+                                'suberrors' =>
182
+                                    array (
183
+                                        'code' => 1,
184
+                                        'msg' => '',
185
+                                        'path' =>
186
+                                            array (
187
+                                                0 => 1,
188
+                                            ),
189
+                                    ),
190
+                            ),
191
+                    ),
192
+            ),
193 193
             $res->data['updateBooks']
194 194
         );
195 195
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                 'title' => [
63 63
                     'type' => Type::string(),
64 64
                     'description' => 'Enter a book title, no more than 10 characters in length',
65
-                    'validate' => static function (string $title) {
65
+                    'validate' => static function(string $title) {
66 66
                         if (strlen($title) > 10) {
67 67
                             return [1, 'book title must be less than 10 chaacters'];
68 68
                         }
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
                         'unknownAuthor',
77 77
                         'authorDeceased',
78 78
                     ],
79
-                    'validate' => function (string $authorId) {
80
-                        if (! isset($this->data['people'][$authorId])) {
79
+                    'validate' => function(string $authorId) {
80
+                        if (!isset($this->data['people'][$authorId])) {
81 81
                             return ['unknownAuthor', 'We have no record of that author'];
82 82
                         }
83 83
                         return 0;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
             'query' => $this->query,
93 93
             'mutation' => new ObjectType([
94 94
                 'name' => 'Mutation',
95
-                'fields' => function () {
95
+                'fields' => function() {
96 96
                     return [
97 97
                         'updateBooks' => new ValidatedFieldDefinition([
98 98
                             'name' => 'updateBooks',
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
                         	            $i = 5;
105 105
 	                                },
106 106
 	                                'validateItem' => static function($book) {
107
-                        	            $res = isset($book['author']) || isset($book['title']) ? 0: 1;
107
+                        	            $res = isset($book['author']) || isset($book['title']) ? 0 : 1;
108 108
                         	            return $res;
109 109
 	                                }
110 110
                                 ],
111 111
                             ],
112
-                            'resolve' => static function ($value) : bool {
112
+                            'resolve' => static function($value) : bool {
113 113
                                 // ...
114 114
                                 // do update
115 115
                                 // ...
@@ -169,21 +169,21 @@  discard block
 block discarded – undo
169 169
 	    static::assertEmpty($res->errors);
170 170
 
171 171
         static::assertEquals(
172
-	        array (
172
+	        array(
173 173
 		        'valid' => false,
174 174
 		        'result' => NULL,
175 175
 		        'suberrors' =>
176
-			        array (
176
+			        array(
177 177
 				        'bookAttributes' =>
178
-					        array (
178
+					        array(
179 179
 						        'code' => NULL,
180 180
 						        'msg' => NULL,
181 181
 						        'suberrors' =>
182
-							        array (
182
+							        array(
183 183
 								        'code' => 1,
184 184
 								        'msg' => '',
185 185
 								        'path' =>
186
-									        array (
186
+									        array(
187 187
 										        0 => 1,
188 188
 									        ),
189 189
 							        ),
Please login to merge, or discard this patch.
src/Type/Definition/ValidateItemsError.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@
 block discarded – undo
2 2
 namespace GraphQL\Type\Definition;
3 3
 
4 4
 class ValidateItemsError extends \Exception {
5
-	public $path;
6
-	public $error;
7
-	function __construct($path, $error) {
8
-		parent::__construct();
9
-		$this->path = $path;
10
-		$this->error = $error;
11
-	}
5
+    public $path;
6
+    public $error;
7
+    function __construct($path, $error) {
8
+        parent::__construct();
9
+        $this->path = $path;
10
+        $this->error = $error;
11
+    }
12 12
 }
13 13
\ No newline at end of file
Please login to merge, or discard this patch.
tests/Type/UserErrorsType/ListOfTest.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -118,21 +118,21 @@  discard block
 block discarded – undo
118 118
     public function testListOfInputObjectWithValidationOnSelf()
119 119
     {
120 120
         $type  = new UserErrorsType([
121
-	        'validate' => static function(array $authors) {
122
-        	    if(count($authors) < 1) {
123
-        	    	return ['atLeastOneAuthorRequired', "You must submit at least one author"];
124
-	            }
125
-	        },
126
-	        'errorCodes' => ['atLeastOneBookRequired'],
127
-	        'type' => Type::listOf(new InputObjectType([
121
+            'validate' => static function(array $authors) {
122
+                if(count($authors) < 1) {
123
+                    return ['atLeastOneAuthorRequired', "You must submit at least one author"];
124
+                }
125
+            },
126
+            'errorCodes' => ['atLeastOneBookRequired'],
127
+            'type' => Type::listOf(new InputObjectType([
128 128
                 'name'=> 'Author',
129 129
                 'fields' => [
130 130
                     'firstName' => [
131 131
                         'type' => Type::string(),
132 132
                     ],
133
-	                'lastName' => [
134
-		                'type' => Type::string(),
135
-	                ],
133
+                    'lastName' => [
134
+                        'type' => Type::string(),
135
+                    ],
136 136
                 ],
137 137
             ]))
138 138
         ], ['authorList']);
@@ -159,30 +159,30 @@  discard block
 block discarded – undo
159 159
 		'), SchemaPrinter::doPrint(new Schema(['query' => $type])));
160 160
     }
161 161
 
162
-	public function testListOfInputObjectWithValidationOnWrappedSelf()
163
-	{
164
-		$type  = new UserErrorsType([
165
-			'suberrorCodes' => ['firstNameOrLastNameRequired'],
166
-			'validateItem' => static function(array $author) {
167
-				if(!isset($author['firstName']) && !isset($author['lastName'])) {
168
-					return ['atLeastOneAuthorRequired', "You must submit a first name or a last name"];
169
-				}
170
-			},
171
-			'type' => Type::listOf(new InputObjectType([
172
-				'name'=> 'Author',
173
-				'fields' => [
174
-					'firstName' => [
175
-						'type' => Type::string(),
176
-						'validate' => function(string $name) {}
177
-					],
178
-					'lastName' => [
179
-						'type' => Type::string(),
180
-					],
181
-				],
182
-			]))
183
-		], ['authorList']);
184
-
185
-		self::assertEquals(Utils::nowdoc('
162
+    public function testListOfInputObjectWithValidationOnWrappedSelf()
163
+    {
164
+        $type  = new UserErrorsType([
165
+            'suberrorCodes' => ['firstNameOrLastNameRequired'],
166
+            'validateItem' => static function(array $author) {
167
+                if(!isset($author['firstName']) && !isset($author['lastName'])) {
168
+                    return ['atLeastOneAuthorRequired', "You must submit a first name or a last name"];
169
+                }
170
+            },
171
+            'type' => Type::listOf(new InputObjectType([
172
+                'name'=> 'Author',
173
+                'fields' => [
174
+                    'firstName' => [
175
+                        'type' => Type::string(),
176
+                        'validate' => function(string $name) {}
177
+                    ],
178
+                    'lastName' => [
179
+                        'type' => Type::string(),
180
+                    ],
181
+                ],
182
+            ]))
183
+        ], ['authorList']);
184
+
185
+        self::assertEquals(Utils::nowdoc('
186 186
 			schema {
187 187
 			  query: AuthorListError
188 188
 			}
@@ -229,5 +229,5 @@  discard block
 block discarded – undo
229 229
 			}
230 230
 
231 231
 		'), SchemaPrinter::doPrint(new Schema(['query' => $type])));
232
-	}
232
+    }
233 233
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $type = new UserErrorsType([
39 39
             'type' => Type::listOf(Type::id()),
40 40
             'errorCodes'=> ['atLeastOneRequired'],
41
-            'validate' => static function ($value) {
41
+            'validate' => static function($value) {
42 42
                 return 0;
43 43
             },
44 44
         ], ['users']);
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
         $type = new UserErrorsType([
71 71
             'type' => Type::listOf(Type::listOf(Type::listOf(Type::id()))),
72 72
             'errorCodes'=> ['atLeastOneRequired'],
73
-            'validate' => static function ($value) {
73
+            'validate' => static function($value) {
74 74
                 return 0;
75 75
             },
76
-            'validateItem' => static function ($value) {
76
+            'validateItem' => static function($value) {
77 77
                 return 0;
78 78
             }
79 79
         ], ['users']);
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 
118 118
     public function testListOfInputObjectWithValidationOnSelf()
119 119
     {
120
-        $type  = new UserErrorsType([
120
+        $type = new UserErrorsType([
121 121
 	        'validate' => static function(array $authors) {
122
-        	    if(count($authors) < 1) {
122
+        	    if (count($authors) < 1) {
123 123
         	    	return ['atLeastOneAuthorRequired', "You must submit at least one author"];
124 124
 	            }
125 125
 	        },
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 
162 162
 	public function testListOfInputObjectWithValidationOnWrappedSelf()
163 163
 	{
164
-		$type  = new UserErrorsType([
164
+		$type = new UserErrorsType([
165 165
 			'suberrorCodes' => ['firstNameOrLastNameRequired'],
166 166
 			'validateItem' => static function(array $author) {
167
-				if(!isset($author['firstName']) && !isset($author['lastName'])) {
167
+				if (!isset($author['firstName']) && !isset($author['lastName'])) {
168 168
 					return ['atLeastOneAuthorRequired', "You must submit a first name or a last name"];
169 169
 				}
170 170
 			},
Please login to merge, or discard this patch.
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.