@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | 'fields' => [ |
56 | 56 | 'title' => [ |
57 | 57 | 'type' => Type::string(), |
58 | - 'resolve' => static function ($book) { |
|
58 | + 'resolve' => static function($book) { |
|
59 | 59 | return $book['title']; |
60 | 60 | }, |
61 | 61 | ], |
62 | 62 | 'author' => [ |
63 | 63 | 'type' => $this->personType, |
64 | - 'resolve' => static function ($book) { |
|
64 | + 'resolve' => static function($book) { |
|
65 | 65 | return $book['author']; |
66 | 66 | }, |
67 | 67 | ], |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | 'query' => $this->query, |
75 | 75 | 'mutation' => new ObjectType([ |
76 | 76 | 'name' => 'Mutation', |
77 | - 'fields' => function () { |
|
77 | + 'fields' => function() { |
|
78 | 78 | return [ |
79 | 79 | 'updateBook' => new ValidatedFieldDefinition([ |
80 | 80 | 'name' => 'updateBook', |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'bookId' => [ |
84 | 84 | 'type' => Type::id(), |
85 | 85 | 'errorCodes' => ['bookNotFound'], |
86 | - 'validate' => function ($bookId) { |
|
86 | + 'validate' => function($bookId) { |
|
87 | 87 | if (isset($this->data['books'][$bookId])) { |
88 | 88 | return 0; |
89 | 89 | } |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | }, |
93 | 93 | ], |
94 | 94 | ], |
95 | - 'resolve' => static function ($value) : bool { |
|
96 | - return ! ! $value; |
|
95 | + 'resolve' => static function($value) : bool { |
|
96 | + return !!$value; |
|
97 | 97 | }, |
98 | 98 | ]), |
99 | 99 | ]; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $type = new UserErrorsType([ |
40 | 40 | 'type' => Type::listOf(Type::id()), |
41 | 41 | 'errorCodes'=> ['atLeastOneRequired'], |
42 | - 'validate' => static function ($value) { |
|
42 | + 'validate' => static function($value) { |
|
43 | 43 | return $value ? 0 : 1; |
44 | 44 | }, |
45 | 45 | ], ['users']); |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | $type = new UserErrorsType([ |
72 | 72 | 'type' => Type::listOf(Type::listOf(Type::listOf(Type::id()))), |
73 | 73 | 'errorCodes'=> ['atLeastOneRequired'], |
74 | - 'validate' => static function ($value) { |
|
74 | + 'validate' => static function($value) { |
|
75 | 75 | return $value ? 0 : 1; |
76 | 76 | }, |
77 | - 'validateItem' => static function ($value) { |
|
77 | + 'validateItem' => static function($value) { |
|
78 | 78 | return $value ? 0 : 1; |
79 | 79 | }, |
80 | 80 | ], ['users']); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function testListOfInputObjectWithValidationOnSelf() |
120 | 120 | { |
121 | 121 | $type = new UserErrorsType([ |
122 | - 'validate' => static function (array $authors) { |
|
122 | + 'validate' => static function(array $authors) { |
|
123 | 123 | if (count($authors) < 1) { |
124 | 124 | return ['atLeastOneAuthorRequired', 'You must submit at least one author']; |
125 | 125 | } |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | { |
165 | 165 | $type = new UserErrorsType([ |
166 | 166 | 'suberrorCodes' => ['firstNameOrLastNameRequired'], |
167 | - 'validateItem' => static function (array $author) { |
|
168 | - if (! isset($author['firstName']) && ! isset($author['lastName'])) { |
|
167 | + 'validateItem' => static function(array $author) { |
|
168 | + if (!isset($author['firstName']) && !isset($author['lastName'])) { |
|
169 | 169 | return ['atLeastOneAuthorRequired', 'You must submit a first name or a last name']; |
170 | 170 | } |
171 | 171 | }, |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | 'fields' => [ |
175 | 175 | 'firstName' => [ |
176 | 176 | 'type' => Type::string(), |
177 | - 'validate' => static function (string $name) { |
|
177 | + 'validate' => static function(string $name) { |
|
178 | 178 | return $name ? 0 : 1; |
179 | 179 | }, |
180 | 180 | ], |
@@ -61,7 +61,7 @@ discard block |
||
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 |
||
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 |
||
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', |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | 'bookAttributes' => [ |
101 | 101 | 'type' => $this->bookAttributesInputType, |
102 | 102 | 'errorCodes' => ['titleOrIdRequired'], |
103 | - 'validate' => static function (?array $bookAttributes) { |
|
103 | + 'validate' => static function(?array $bookAttributes) { |
|
104 | 104 | if (empty($bookAttributes)) { |
105 | 105 | return 0; |
106 | 106 | } |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | }, |
113 | 113 | ], |
114 | 114 | ], |
115 | - 'resolve' => static function ($value) : bool { |
|
115 | + 'resolve' => static function($value) : bool { |
|
116 | 116 | // ... |
117 | 117 | // do update |
118 | 118 | // ... |
119 | 119 | |
120 | - return ! $value; |
|
120 | + return !$value; |
|
121 | 121 | }, |
122 | 122 | ]), |
123 | 123 | ]; |
@@ -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' => ['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) : bool { |
|
56 | + 'resolve' => static function(array $phoneNumbers) : bool { |
|
57 | 57 | return !empty($phoneNumbers); |
58 | 58 | }, |
59 | 59 | ]), |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | [ |
107 | 107 | 'suberrors' => |
108 | 108 | [ |
109 | - 'path' => [0,1], |
|
109 | + 'path' => [0, 1], |
|
110 | 110 | 'code' => 'invalidPhoneNumber', |
111 | 111 | ], |
112 | 112 | ], |