@@ -22,7 +22,7 @@ |
||
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 = []; |
@@ -337,7 +337,7 @@ |
||
337 | 337 | 'validateItem' => static function ($value) { |
338 | 338 | return $value ? 0 : 1; |
339 | 339 | } |
340 | - ] |
|
340 | + ] |
|
341 | 341 | ] |
342 | 342 | ]), ' |
343 | 343 | type Mutation { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | 'resolve' => static function (array $data) : bool { |
57 | 57 | return !empty($data); |
58 | 58 | }, |
59 | - ]),' |
|
59 | + ]), ' |
|
60 | 60 | type Mutation { |
61 | 61 | updateAddressBook(phoneNumbers: [String]): UpdateAddressBookResult |
62 | 62 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | 'resolve' => static function (array $data) : bool { |
130 | 130 | return !empty($data); |
131 | 131 | }, |
132 | - ]),' |
|
132 | + ]), ' |
|
133 | 133 | input Address { |
134 | 134 | city: String |
135 | 135 | zip: Int |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'errorCodes' => [ |
192 | 192 | 'invalidCity' |
193 | 193 | ], |
194 | - 'validate' => function($city) { |
|
194 | + 'validate' => function ($city) { |
|
195 | 195 | if ($city == "Toledo") { |
196 | 196 | return ['invalidCity', "Sorry, Toledo is not allowed"]; |
197 | 197 | } |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | 'type' => Type::string() |
201 | 201 | ], |
202 | 202 | 'zip' => [ |
203 | - 'errorCodes' => ['invalidZip', 'tooFarAway' ], |
|
204 | - 'validate' => function($zip) { |
|
205 | - if(!is_numeric($zip)) { |
|
203 | + 'errorCodes' => ['invalidZip', 'tooFarAway'], |
|
204 | + 'validate' => function ($zip) { |
|
205 | + if (!is_numeric($zip)) { |
|
206 | 206 | return ["invalidZip", "Invalid zip format; should be numeric"]; |
207 | 207 | } |
208 | 208 | return 0; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | 'resolve' => static function (array $data) : bool { |
224 | 224 | return !empty($data); |
225 | 225 | }, |
226 | - ]),' |
|
226 | + ]), ' |
|
227 | 227 | input Address { |
228 | 228 | city: String |
229 | 229 | zip: Int |
@@ -314,12 +314,12 @@ discard block |
||
314 | 314 | |
315 | 315 | public function testListOfListOfListOfScalarWithValidationOnSelfAndWrappedType(): void |
316 | 316 | { |
317 | - $this->_checkSchema( new ValidatedFieldDefinition([ |
|
317 | + $this->_checkSchema(new ValidatedFieldDefinition([ |
|
318 | 318 | 'type' => Type::boolean(), |
319 | 319 | 'name' => 'updateAddressBook', |
320 | 320 | 'errorCodes' => ['atLeastOnePhoneNumberRequired'], |
321 | - 'validate' => static function($data) { |
|
322 | - if(empty($data['phoneNumbers'])) { |
|
321 | + 'validate' => static function ($data) { |
|
322 | + if (empty($data['phoneNumbers'])) { |
|
323 | 323 | return ['atLeastOnePhoneNumberRequired', "You must provide at least one phone number"]; |
324 | 324 | } |
325 | 325 | return 0; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | 'type' => Type::listOf(Type::listOf(Type::listOf(Type::id()))), |
330 | 330 | 'errorCodes'=> ['mustHaveSevenDigits'], |
331 | 331 | 'validate' => static function ($phoneNumber) { |
332 | - if(strlen($phoneNumber) != 7) { |
|
332 | + if (strlen($phoneNumber) != 7) { |
|
333 | 333 | return ['mustHaveSevenDigits', "Phone numbers must have 7 digits"]; |
334 | 334 | } |
335 | 335 | return 0; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | 'resolve' => static function (array $data) : bool { |
37 | 37 | return !empty($data); |
38 | 38 | }, |
39 | - ]),' |
|
39 | + ]), ' |
|
40 | 40 | """User errors for DeleteAuthor""" |
41 | 41 | type DeleteAuthorResult { |
42 | 42 | """The payload, if any""" |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | 'firstName' => [ |
91 | 91 | 'type' => Type::string(), |
92 | 92 | 'description' => 'A first name', |
93 | - 'validate' => static function($firstName) { |
|
94 | - if(strlen($firstName > 100)) { |
|
93 | + 'validate' => static function ($firstName) { |
|
94 | + if (strlen($firstName > 100)) { |
|
95 | 95 | return 1; |
96 | 96 | } |
97 | 97 | return 0; |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | 'lastName' => [ |
101 | 101 | 'type' => Type::string(), |
102 | 102 | 'description' => 'A last name', |
103 | - 'validate' => static function($lastName) { |
|
104 | - if(strlen($lastName > 100)) { |
|
103 | + 'validate' => static function ($lastName) { |
|
104 | + if (strlen($lastName > 100)) { |
|
105 | 105 | return 1; |
106 | 106 | } |
107 | 107 | return 0; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | 'resolve' => static function (array $data) : bool { |
125 | 125 | return !empty($data); |
126 | 126 | }, |
127 | - ]),' |
|
127 | + ]), ' |
|
128 | 128 | type Mutation { |
129 | 129 | updateAuthor(author: bookInput!): UpdateAuthorResult |
130 | 130 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | ); |
97 | 97 | |
98 | 98 | static::assertEquals( |
99 | - array ( |
|
99 | + array( |
|
100 | 100 | 'valid' => false, |
101 | 101 | 'fields' => |
102 | 102 | [ |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | ); |
154 | 154 | |
155 | 155 | static::assertEquals( |
156 | - array ( |
|
156 | + array( |
|
157 | 157 | 'valid' => false, |
158 | 158 | 'code' => 'atLeastOneList', |
159 | 159 | 'msg' => 'You must submit at least one list of numbers', |
@@ -220,7 +220,7 @@ |
||
220 | 220 | ); |
221 | 221 | |
222 | 222 | static::assertEquals( |
223 | - array ( |
|
223 | + array( |
|
224 | 224 | 'valid' => false, |
225 | 225 | 'fields' => |
226 | 226 | [ |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | 'name' => 'updateBooks', |
103 | 103 | 'type' => Type::boolean(), |
104 | 104 | 'validate' => static function ($book) { |
105 | - return isset($book['author']) || isset($book['title']) ? 0: [1, 'You must set an author or a title']; |
|
105 | + return isset($book['author']) || isset($book['title']) ? 0 : [1, 'You must set an author or a title']; |
|
106 | 106 | }, |
107 | 107 | 'args' => [ |
108 | 108 | 'bookAttributes' => [ |
109 | 109 | 'type' => Type::listOf($this->bookAttributesInputType), |
110 | 110 | 'validate' => static function ($var) { |
111 | - return $var ? 0: 1; |
|
111 | + return $var ? 0 : 1; |
|
112 | 112 | }, |
113 | 113 | ], |
114 | 114 | ], |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | static::assertEmpty($res->errors); |
167 | 167 | |
168 | 168 | static::assertEquals( |
169 | - array ( |
|
169 | + array( |
|
170 | 170 | 'valid' => false, |
171 | 171 | 'result' => null, |
172 | 172 | 'code' => 1, |
@@ -52,7 +52,7 @@ |
||
52 | 52 | |
53 | 53 | protected function _getType($config) { |
54 | 54 | $type = $config['type']; |
55 | - if($type instanceof NonNull || $type instanceof ListOfType) { |
|
55 | + if ($type instanceof NonNull || $type instanceof ListOfType) { |
|
56 | 56 | $type = $type->getWrappedType(true); |
57 | 57 | } |
58 | 58 | return $type; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | 'name' => 'updateBook', |
39 | 39 | 'args' => [ |
40 | 40 | 'book' => [ |
41 | - 'validate' => static function($book) { |
|
41 | + 'validate' => static function ($book) { |
|
42 | 42 | return empty($book) ? 1 : 0; |
43 | 43 | }, |
44 | 44 | 'type' => new InputObjectType([ |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | 'fields' => [ |
47 | 47 | 'title' => [ |
48 | 48 | 'type' => Type::string(), |
49 | - 'validate' => static function() { return 0; } |
|
49 | + 'validate' => static function () { return 0; } |
|
50 | 50 | ], |
51 | 51 | 'authorId' => [ |
52 | 52 | 'errorCodes' => ['unknownAuthor'], |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'name' => $name, |
65 | 65 | 'resolve' => function ($value, $args1, $context, $info) use ($config, $args) { |
66 | 66 | // validate inputs |
67 | - $config['type'] = new InputObjectType([ |
|
67 | + $config['type'] = new InputObjectType([ |
|
68 | 68 | 'name'=>'', |
69 | 69 | 'fields' => $args, |
70 | 70 | ]); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | if ($arr === []) { |
90 | 90 | return false; |
91 | 91 | } |
92 | - return array_keys($arr) !== range(0, count($arr) - 1); |
|
92 | + return array_keys($arr) !== range(0, count($arr)-1); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | $newPath[] = 0; |
108 | 108 | $this->_validateItems($config, $subValue, $newPath, $validate); |
109 | 109 | } else { |
110 | - $path[count($path) - 1] = $idx; |
|
110 | + $path[count($path)-1] = $idx; |
|
111 | 111 | $err = $validate($subValue); |
112 | 112 | |
113 | - if(empty($err)) { |
|
113 | + if (empty($err)) { |
|
114 | 114 | $wrappedType = $config['type']->getWrappedType(true); |
115 | 115 | $err = $this->_validate([ |
116 | 116 | 'type' => $wrappedType |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $fields = $type->getFields(); |
190 | 190 | if (is_array($value)) { |
191 | 191 | foreach ($value as $key => $subValue) { |
192 | - $config = $fields[$key]->config; |
|
192 | + $config = $fields[$key]->config; |
|
193 | 193 | $res['errors'][$key] = $this->_validate($config, $subValue); |
194 | 194 | } |
195 | 195 | $res['errors'] = array_filter($res['errors'] ?? []); |