@@ -37,7 +37,7 @@ |
||
| 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']), |
@@ -93,10 +93,10 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -31,7 +31,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | ), |
@@ -100,13 +100,13 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -62,7 +62,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | ), |