Passed
Pull Request — master (#1)
by Max
05:09
created
src/Type/Definition/UserErrorsType.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -26,33 +26,33 @@
 block discarded – undo
26 26
         GraphQL\Utils\Utils::invariant($config['type'] instanceof Type, 'Must provide type.');
27 27
 
28 28
         if (isset($config['errorCodes'])) {
29
-        	if(isset($config['validate'])) {
30
-		        /** code property */
31
-		        $finalFields['code'] = [
32
-			        'type' => $this->_set(new EnumType([
33
-				        'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode',
34
-				        'description' => 'Error code',
35
-				        'values' => $config['errorCodes'],
36
-			        ]), $config),
37
-			        'description' => 'An error code',
38
-			        'resolve' => static function ($value) {
39
-				        return $value['error'][0] ?? null;
40
-			        },
41
-		        ];
42
-
43
-		        /**
44
-		         * msg property
45
-		         */
46
-		        $finalFields['msg'] = [
47
-			        'type' => Type::string(),
48
-			        'description' => 'A natural language description of the issue',
49
-			        'resolve' => static function ($value) {
50
-				        return $value['error'][1] ?? null;
51
-			        },
52
-		        ];
53
-	        } else {
54
-        		throw new \Exception("If you specify errorCodes, you must also provide a validate callback");
55
-	        }
29
+            if(isset($config['validate'])) {
30
+                /** code property */
31
+                $finalFields['code'] = [
32
+                    'type' => $this->_set(new EnumType([
33
+                        'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode',
34
+                        'description' => 'Error code',
35
+                        'values' => $config['errorCodes'],
36
+                    ]), $config),
37
+                    'description' => 'An error code',
38
+                    'resolve' => static function ($value) {
39
+                        return $value['error'][0] ?? null;
40
+                    },
41
+                ];
42
+
43
+                /**
44
+                 * msg property
45
+                 */
46
+                $finalFields['msg'] = [
47
+                    'type' => Type::string(),
48
+                    'description' => 'A natural language description of the issue',
49
+                    'resolve' => static function ($value) {
50
+                        return $value['error'][1] ?? null;
51
+                    },
52
+                ];
53
+            } else {
54
+                throw new \Exception("If you specify errorCodes, you must also provide a validate callback");
55
+            }
56 56
         }
57 57
 
58 58
         $type = $config['type'];
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         GraphQL\Utils\Utils::invariant($config['type'] instanceof Type, 'Must provide type.');
27 27
 
28 28
         if (isset($config['errorCodes'])) {
29
-        	if(isset($config['validate'])) {
29
+        	if (isset($config['validate'])) {
30 30
 		        /** code property */
31 31
 		        $finalFields['code'] = [
32 32
 			        'type' => $this->_set(new EnumType([
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 				        'values' => $config['errorCodes'],
36 36
 			        ]), $config),
37 37
 			        'description' => 'An error code',
38
-			        'resolve' => static function ($value) {
38
+			        'resolve' => static function($value) {
39 39
 				        return $value['error'][0] ?? null;
40 40
 			        },
41 41
 		        ];
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		        $finalFields['msg'] = [
47 47
 			        'type' => Type::string(),
48 48
 			        'description' => 'A natural language description of the issue',
49
-			        'resolve' => static function ($value) {
49
+			        'resolve' => static function($value) {
50 50
 				        return $value['error'][1] ?? null;
51 51
 			        },
52 52
 		        ];
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
             $fields = [];
61 61
             foreach ($type->getFields() as $key => $field) {
62 62
                 $newType = static::create(
63
-                    $field->config + ['typeSetter' => $config['typeSetter'] ?? null],
63
+                    $field->config+['typeSetter' => $config['typeSetter'] ?? null],
64 64
                     array_merge($path, [$key])
65 65
                 );
66 66
 
67
-                if (! $newType) {
67
+                if (!$newType) {
68 68
                     continue;
69 69
                 }
70 70
 
71 71
                 $fields[$key] = [
72 72
                     'description' => 'Error for ' . $key,
73 73
                     'type' => $newType,
74
-                    'resolve' => static function ($value) use ($key) {
74
+                    'resolve' => static function($value) use ($key) {
75 75
                         return $value[$key] ?? null;
76 76
                     },
77 77
                 ];
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                         'fields' => $fields,
89 89
                     ]), $config),
90 90
                     'description' => 'Suberrors for ' . ucfirst($path[count($path)-1]),
91
-                    'resolve' => static function (array $value) {
91
+                    'resolve' => static function(array $value) {
92 92
                         return $value['suberrors'] ?? null;
93 93
                     },
94 94
                 ];
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                 $finalFields['suberrors'] = [
113 113
                     'description' => 'Suberrors for the list of ' . $type->ofType . ' items',
114 114
                     'type' => $newType,
115
-                    'resolve' => static function ($value) {
115
+                    'resolve' => static function($value) {
116 116
                         return $value['suberrors'] ?? null;
117 117
                     },
118 118
                 ];
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             $finalFields['path'] = [
127 127
                 'type' => Type::listOf(Type::int()),
128 128
                 'description' => 'A path describing this items\'s location in the nested array',
129
-                'resolve' => static function ($value) {
129
+                'resolve' => static function($value) {
130 130
                     return $value['path'];
131 131
                 },
132 132
             ];
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             $config['fields']['code'] = $config['fields']['code'] ?? [
164 164
                 'type' => Type::int(),
165 165
                 'description' => 'A numeric error code. 0 on success, non-zero on failure.',
166
-                'resolve' => static function ($value) {
166
+                'resolve' => static function($value) {
167 167
                     $error = $value['error'] ?? null;
168 168
                     switch (gettype($error)) {
169 169
                         case 'integer':
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             $config['fields']['msg'] = $config['fields']['msg'] ?? [
177 177
                 'type' => Type::string(),
178 178
                 'description' => 'An error message.',
179
-                'resolve' => static function ($value) {
179
+                'resolve' => static function($value) {
180 180
                     $error = $value['error'] ?? null;
181 181
                     switch (gettype($error)) {
182 182
                         case 'integer':
Please login to merge, or discard this patch.
src/Type/Definition/ValidatedFieldDefinition.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -90,11 +90,11 @@
 block discarded – undo
90 90
         ]);
91 91
     }
92 92
 
93
-	protected function _isAssoc(array $arr)
94
-	{
95
-		if (array() === $arr) return false;
96
-		return array_keys($arr) !== range(0, count($arr) - 1);
97
-	}
93
+    protected function _isAssoc(array $arr)
94
+    {
95
+        if (array() === $arr) return false;
96
+        return array_keys($arr) !== range(0, count($arr) - 1);
97
+    }
98 98
 
99 99
     protected function _validateItems($value, array $path, callable $validate) {
100 100
         foreach ($value as $idx => $subValue) {
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
         $this->typeSetter = $config['typeSetter'] ?? null;
39 39
 
40
-        if (! isset($config['type'])) {
40
+        if (!isset($config['type'])) {
41 41
             throw new Exception('You must specify a type for your field');
42 42
         }
43 43
 
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
                 'result' => [
48 48
                     'type' => $config['type'],
49 49
                     'description' => 'The payload, if any',
50
-                    'resolve' => static function ($value) {
50
+                    'resolve' => static function($value) {
51 51
                         return $value['result'] ?? null;
52 52
                     },
53 53
                 ],
54 54
                 'valid' => [
55 55
                     'type' => Type::nonNull(Type::boolean()),
56 56
                     'description' => 'Whether all validation passed. True for yes, false for no.',
57
-                    'resolve' => static function ($value) {
57
+                    'resolve' => static function($value) {
58 58
                         return $value['valid'];
59 59
                     },
60 60
                 ],
@@ -71,17 +71,17 @@  discard block
 block discarded – undo
71 71
             'type' => $type,
72 72
             'args' => $args,
73 73
             'name' => $name,
74
-            'resolve' => function ($value, $args1, $context, $info) use ($config, $args) {
74
+            'resolve' => function($value, $args1, $context, $info) use ($config, $args) {
75 75
                 // validate inputs
76
-                $config['type']  = new InputObjectType([
76
+                $config['type'] = new InputObjectType([
77 77
                     'name'=>'',
78 78
                     'fields' => $args,
79 79
                 ]);
80 80
                 $errors          = $this->_validate($config, $args1);
81 81
                 $result          = $errors;
82
-                $result['valid'] = ! $errors;
82
+                $result['valid'] = !$errors;
83 83
 
84
-                if (! isset($result['error']) && ! isset($result['suberrors'])) {
84
+                if (!isset($result['error']) && !isset($result['suberrors'])) {
85 85
                     $result['result'] = $config['resolve']($value, $args1, $context, $info);
86 86
                 }
87 87
 
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	protected function _isAssoc(array $arr)
94 94
 	{
95 95
 		if (array() === $arr) return false;
96
-		return array_keys($arr) !== range(0, count($arr) - 1);
96
+		return array_keys($arr) !== range(0, count($arr)-1);
97 97
 	}
98 98
 
99 99
     protected function _validateItems($value, array $path, callable $validate) {
100 100
         foreach ($value as $idx => $subValue) {
101
-            if(is_array($subValue) && !$this->_isAssoc($subValue)) {
101
+            if (is_array($subValue) && !$this->_isAssoc($subValue)) {
102 102
                 $path[count($path)-1] = $idx;
103 103
                 $newPath = $path;
104 104
                 $newPath[] = 0;
105 105
                 $this->_validateItems($subValue, $newPath, $validate);
106 106
             }
107 107
             else {
108
-                $path[count($path) - 1] = $idx;
108
+                $path[count($path)-1] = $idx;
109 109
                 $err = $validate($subValue);
110 110
 
111 111
                 if ($err) {
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
                     }
134 134
                 }
135 135
 
136
-                if(isset($arg['validateItem'])) {
136
+                if (isset($arg['validateItem'])) {
137 137
                     try {
138 138
                         $this->_validateItems($value, [0], $arg['validateItem']);
139 139
                     }
140
-                    catch(ValidateItemsError $e) {
140
+                    catch (ValidateItemsError $e) {
141 141
                         $res['suberrors'] = [
142 142
                             'error' => $e->error,
143 143
                             'path' => $e->path
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -92,7 +92,9 @@  discard block
 block discarded – undo
92 92
 
93 93
 	protected function _isAssoc(array $arr)
94 94
 	{
95
-		if (array() === $arr) return false;
95
+		if (array() === $arr) {
96
+		    return false;
97
+		}
96 98
 		return array_keys($arr) !== range(0, count($arr) - 1);
97 99
 	}
98 100
 
@@ -103,8 +105,7 @@  discard block
 block discarded – undo
103 105
                 $newPath = $path;
104 106
                 $newPath[] = 0;
105 107
                 $this->_validateItems($subValue, $newPath, $validate);
106
-            }
107
-            else {
108
+            } else {
108 109
                 $path[count($path) - 1] = $idx;
109 110
                 $err = $validate($subValue);
110 111
 
@@ -136,8 +137,7 @@  discard block
 block discarded – undo
136 137
                 if(isset($arg['validateItem'])) {
137 138
                     try {
138 139
                         $this->_validateItems($value, [0], $arg['validateItem']);
139
-                    }
140
-                    catch(ValidateItemsError $e) {
140
+                    } catch(ValidateItemsError $e) {
141 141
                         $res['suberrors'] = [
142 142
                             'error' => $e->error,
143 143
                             'path' => $e->path
Please login to merge, or discard this patch.
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/ListOfTest.php 2 patches
Indentation   +40 added lines, -40 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,35 +159,35 @@  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
-			'validateItem' => static function(array $author) {
184
-				if(!isset($author['firstName']) && !isset($author['lastName'])) {
185
-					return ['atLeastOneAuthorRequired', "You must submit a first name or a last name"];
186
-				}
187
-			}
188
-		], ['authorList']);
189
-
190
-		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
+            'validateItem' => static function(array $author) {
184
+                if(!isset($author['firstName']) && !isset($author['lastName'])) {
185
+                    return ['atLeastOneAuthorRequired', "You must submit a first name or a last name"];
186
+                }
187
+            }
188
+        ], ['authorList']);
189
+
190
+        self::assertEquals(Utils::nowdoc('
191 191
 			schema {
192 192
 			  query: AuthorListError
193 193
 			}
@@ -234,5 +234,5 @@  discard block
 block discarded – undo
234 234
 			}
235 235
 
236 236
 		'), SchemaPrinter::doPrint(new Schema(['query' => $type])));
237
-	}
237
+    }
238 238
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 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
 			},
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 				],
182 182
 			])),
183 183
 			'validateItem' => static function(array $author) {
184
-				if(!isset($author['firstName']) && !isset($author['lastName'])) {
184
+				if (!isset($author['firstName']) && !isset($author['lastName'])) {
185 185
 					return ['atLeastOneAuthorRequired', "You must submit a first name or a last name"];
186 186
 				}
187 187
 			}
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/ListOfScalarValidationTest.php 2 patches
Indentation   +35 added lines, -35 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,
@@ -152,39 +152,39 @@  discard block
 block discarded – undo
152 152
             null,
153 153
             [
154 154
                 'phoneNumbers' => [
155
-                	[],
156
-                	[
157
-	                    '123-4567',
158
-	                    'xxx-7890',
159
-	                    '321-1234'
160
-		            ]
155
+                    [],
156
+                    [
157
+                        '123-4567',
158
+                        'xxx-7890',
159
+                        '321-1234'
160
+                    ]
161 161
                 ],
162 162
             ]
163 163
         );
164 164
 
165 165
         static::assertEmpty($res->errors);
166 166
         static::assertEquals(
167
-	        array (
168
-		        'valid' => false,
169
-		        'suberrors' =>
170
-			        array (
171
-				        'phoneNumbers' =>
172
-					        array (
173
-						        'code' => NULL,
174
-						        'msg' => NULL,
175
-						        'suberrors' =>
176
-							        array (
177
-								        'path' =>
178
-									        array (
179
-										        0 => 1,
180
-										        1 => 1,
181
-									        ),
182
-								        'code' => 'invalidPhoneNumber',
183
-							        ),
184
-					        ),
185
-			        ),
186
-		        'result' => NULL,
187
-	        ),
167
+            array (
168
+                'valid' => false,
169
+                'suberrors' =>
170
+                    array (
171
+                        'phoneNumbers' =>
172
+                            array (
173
+                                'code' => NULL,
174
+                                'msg' => NULL,
175
+                                'suberrors' =>
176
+                                    array (
177
+                                        'path' =>
178
+                                            array (
179
+                                                0 => 1,
180
+                                                1 => 1,
181
+                                            ),
182
+                                        'code' => 'invalidPhoneNumber',
183
+                                    ),
184
+                            ),
185
+                    ),
186
+                'result' => NULL,
187
+            ),
188 188
             $res->data['setPhoneNumbers']
189 189
         );
190 190
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 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' => ['maxNumExceeded'],
43
-                                    'validate' => static function (array $phoneNumbers) {
43
+                                    'validate' => static function(array $phoneNumbers) {
44 44
                                         if (count($phoneNumbers) > 2) {
45 45
                                             return ['maxNumExceeded', 'You may not submit more than 2 lists of phone 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
                             ],
@@ -164,18 +164,18 @@  discard block
 block discarded – undo
164 164
 
165 165
         static::assertEmpty($res->errors);
166 166
         static::assertEquals(
167
-	        array (
167
+	        array(
168 168
 		        'valid' => false,
169 169
 		        'suberrors' =>
170
-			        array (
170
+			        array(
171 171
 				        'phoneNumbers' =>
172
-					        array (
172
+					        array(
173 173
 						        'code' => NULL,
174 174
 						        'msg' => NULL,
175 175
 						        'suberrors' =>
176
-							        array (
176
+							        array(
177 177
 								        'path' =>
178
-									        array (
178
+									        array(
179 179
 										        0 => 1,
180 180
 										        1 => 1,
181 181
 									        ),
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.