@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | class Utils |
15 | 15 | { |
16 | - public static function nowdoc(string $str) : string |
|
16 | + public static function nowdoc (string $str) : string |
|
17 | 17 | { |
18 | 18 | $lines = preg_split('/\\n/', $str); |
19 | 19 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | // Toss out the first and last lines. |
29 | - $lines = array_slice($lines, 1, count($lines) - 2); |
|
29 | + $lines = array_slice($lines, 1, count($lines)-2); |
|
30 | 30 | |
31 | 31 | // take the tabs from the first line, and subtract them from all lines |
32 | 32 | $matches = []; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** @var Schema */ |
37 | 37 | protected $schema; |
38 | 38 | |
39 | - protected function setUp() |
|
39 | + protected function setUp () |
|
40 | 40 | { |
41 | 41 | $this->personType = new ObjectType([ |
42 | 42 | 'name' => 'Person', |
@@ -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 | ], |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->schema = new Schema([ |
72 | 72 | 'mutation' => new ObjectType([ |
73 | 73 | 'name' => 'Mutation', |
74 | - 'fields' => function () { |
|
74 | + 'fields' => function() { |
|
75 | 75 | return [ |
76 | 76 | 'updateBook' => new ValidatedFieldDefinition([ |
77 | 77 | 'name' => 'updateBook', |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | 'bookId' => [ |
81 | 81 | 'type' => Type::nonNull(Type::id()), |
82 | 82 | 'errorCodes' => ['bookNotFound'], |
83 | - 'validate' => function ($bookId) { |
|
83 | + 'validate' => function($bookId) { |
|
84 | 84 | if (isset($this->data['books'][$bookId])) { |
85 | 85 | return 0; |
86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | }, |
90 | 90 | ], |
91 | 91 | ], |
92 | - 'resolve' => function ($value, $args) : array { |
|
92 | + 'resolve' => function($value, $args) : array { |
|
93 | 93 | return $this->data['books'][$args['bookId']]; |
94 | 94 | }, |
95 | 95 | ]), |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | ]); |
100 | 100 | } |
101 | 101 | |
102 | - public function testNonNullScalarValidationSuccess() |
|
102 | + public function testNonNullScalarValidationSuccess () |
|
103 | 103 | { |
104 | 104 | $res = GraphQL::executeQuery( |
105 | 105 | $this->schema, |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | static::assertTrue($res->data['updateBook']['valid']); |
130 | 130 | } |
131 | 131 | |
132 | - public function testNonNullScalarValidationFail() |
|
132 | + public function testNonNullScalarValidationFail () |
|
133 | 133 | { |
134 | 134 | $res = GraphQL::executeQuery( |
135 | 135 | $this->schema, |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** @var Schema */ |
43 | 43 | protected $schema; |
44 | 44 | |
45 | - protected function setUp() |
|
45 | + protected function setUp () |
|
46 | 46 | { |
47 | 47 | $this->personType = new ObjectType([ |
48 | 48 | 'name' => 'Person', |
@@ -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', |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | 'args' => [ |
101 | 101 | 'bookAttributes' => [ |
102 | 102 | 'type' => Type::listOf($this->bookAttributesInputType), |
103 | - 'validate' => static function ($var) { |
|
104 | - return $var ? 0: 1; |
|
103 | + 'validate' => static function($var) { |
|
104 | + return $var ? 0 : 1; |
|
105 | 105 | }, |
106 | - 'validateItem' => static function ($book) { |
|
107 | - return isset($book['author']) || isset($book['title']) ? 0: 1; |
|
106 | + 'validateItem' => static function($book) { |
|
107 | + return isset($book['author']) || isset($book['title']) ? 0 : 1; |
|
108 | 108 | }, |
109 | 109 | ], |
110 | 110 | ], |
111 | - 'resolve' => static function ($value) : bool { |
|
112 | - return ! ! $value; |
|
111 | + 'resolve' => static function($value) : bool { |
|
112 | + return !!$value; |
|
113 | 113 | }, |
114 | 114 | ]), |
115 | 115 | ]; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | ]); |
119 | 119 | } |
120 | 120 | |
121 | - public function testValidationFail() |
|
121 | + public function testValidationFail () |
|
122 | 122 | { |
123 | 123 | $res = GraphQL::executeQuery( |
124 | 124 | $this->schema, |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | /** @var Schema */ |
25 | 25 | protected $schema; |
26 | 26 | |
27 | - protected function setUp() |
|
27 | + protected function setUp () |
|
28 | 28 | { |
29 | 29 | $this->query = new ObjectType(['name' => 'Query']); |
30 | 30 | $this->schema = new Schema([ |
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,21 +40,21 @@ 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 { |
|
57 | - return ! empty($phoneNumbers); |
|
56 | + 'resolve' => static function(array $phoneNumbers) : bool { |
|
57 | + return !empty($phoneNumbers); |
|
58 | 58 | }, |
59 | 59 | ]), |
60 | 60 | ]; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ]); |
64 | 64 | } |
65 | 65 | |
66 | - public function testItemsValidationOnWrappedTypeFail() |
|
66 | + public function testItemsValidationOnWrappedTypeFail () |
|
67 | 67 | { |
68 | 68 | $res = GraphQL::executeQuery( |
69 | 69 | $this->schema, |
@@ -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 | ], |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | static::assertFalse($res->data['setPhoneNumbers']['valid']); |
121 | 121 | } |
122 | 122 | |
123 | - public function testItemsValidationOnSelfFail() |
|
123 | + public function testItemsValidationOnSelfFail () |
|
124 | 124 | { |
125 | 125 | $res = GraphQL::executeQuery( |
126 | 126 | $this->schema, |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | static::assertFalse($res->data['setPhoneNumbers']['valid']); |
173 | 173 | } |
174 | 174 | |
175 | - public function testListOfValidationFail() |
|
175 | + public function testListOfValidationFail () |
|
176 | 176 | { |
177 | 177 | $res = GraphQL::executeQuery( |
178 | 178 | $this->schema, |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /** @var Schema */ |
42 | 42 | protected $schema; |
43 | 43 | |
44 | - protected function setUp() |
|
44 | + protected function setUp () |
|
45 | 45 | { |
46 | 46 | $this->personType = new ObjectType([ |
47 | 47 | 'name' => 'Person', |
@@ -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 | ]; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | ]); |
127 | 127 | } |
128 | 128 | |
129 | - public function testValidationInputObjectFieldFail() |
|
129 | + public function testValidationInputObjectFieldFail () |
|
130 | 130 | { |
131 | 131 | $res = GraphQL::executeQuery( |
132 | 132 | $this->schema, |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | static::assertFalse($res->data['updateBook']['valid']); |
197 | 197 | } |
198 | 198 | |
199 | - public function testValidationInputObjectSelfFail() |
|
199 | + public function testValidationInputObjectSelfFail () |
|
200 | 200 | { |
201 | 201 | $res = GraphQL::executeQuery( |
202 | 202 | $this->schema, |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | static::assertFalse($res->data['updateBook']['valid']); |
259 | 259 | } |
260 | 260 | |
261 | - public function testValidationSuccess() |
|
261 | + public function testValidationSuccess () |
|
262 | 262 | { |
263 | 263 | $res = GraphQL::executeQuery( |
264 | 264 | $this->schema, |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | static::assertTrue($res->data['updateBook']['valid']); |
312 | 312 | } |
313 | 313 | |
314 | - public function testValidationEmptyInput() |
|
314 | + public function testValidationEmptyInput () |
|
315 | 315 | { |
316 | 316 | $res = GraphQL::executeQuery( |
317 | 317 | $this->schema, |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | final class BasicTest extends TestCase |
11 | 11 | { |
12 | - public function testInferName() |
|
12 | + public function testInferName () |
|
13 | 13 | { |
14 | 14 | $def = new NamelessDef([ |
15 | 15 | 'type' => Type::boolean(), |
@@ -17,20 +17,20 @@ discard block |
||
17 | 17 | 'bookId' => [ |
18 | 18 | 'type' => Type::id(), |
19 | 19 | 'errorCodes' => ['bookNotFound'], |
20 | - 'validate' => static function ($bookId) { |
|
20 | + 'validate' => static function($bookId) { |
|
21 | 21 | return $bookId ? 0 : 1; |
22 | 22 | }, |
23 | 23 | ], |
24 | 24 | ], |
25 | - 'resolve' => static function ($value) : bool { |
|
26 | - return ! ! $value; |
|
25 | + 'resolve' => static function($value) : bool { |
|
26 | + return !!$value; |
|
27 | 27 | }, |
28 | 28 | ]); |
29 | 29 | |
30 | 30 | static::assertEquals('namelessDef', $def->name); |
31 | 31 | } |
32 | 32 | |
33 | - public function testInferNameNameAlreadyExists() |
|
33 | + public function testInferNameNameAlreadyExists () |
|
34 | 34 | { |
35 | 35 | $def = new NamelessDef([ |
36 | 36 | 'name' => 'FooDef', |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | 'bookId' => [ |
40 | 40 | 'type' => Type::id(), |
41 | 41 | 'errorCodes' => ['bookNotFound'], |
42 | - 'validate' => static function ($bookId) { |
|
42 | + 'validate' => static function($bookId) { |
|
43 | 43 | return $bookId ? 0 : 1; |
44 | 44 | }, |
45 | 45 | ], |
46 | 46 | ], |
47 | - 'resolve' => static function ($value) : bool { |
|
48 | - return ! ! $value; |
|
47 | + 'resolve' => static function($value) : bool { |
|
48 | + return !!$value; |
|
49 | 49 | }, |
50 | 50 | ]); |
51 | 51 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** @var Schema */ |
40 | 40 | protected $schema; |
41 | 41 | |
42 | - protected function setUp() |
|
42 | + protected function setUp () |
|
43 | 43 | { |
44 | 44 | $this->personType = new ObjectType([ |
45 | 45 | 'name' => 'Person', |
@@ -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 | ]; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | ]); |
103 | 103 | } |
104 | 104 | |
105 | - public function testNullableScalarValidationOnNullValueSuccess() |
|
105 | + public function testNullableScalarValidationOnNullValueSuccess () |
|
106 | 106 | { |
107 | 107 | $res = GraphQL::executeQuery( |
108 | 108 | $this->schema, |
@@ -15,18 +15,18 @@ discard block |
||
15 | 15 | |
16 | 16 | final class ErrorCodeTypeGenerationTest extends TestCase |
17 | 17 | { |
18 | - public function testMultipleErrorCodesOnSelf() |
|
18 | + public function testMultipleErrorCodesOnSelf () |
|
19 | 19 | { |
20 | 20 | $types = []; |
21 | 21 | new UserErrorsType([ |
22 | - 'validate' => static function ($val) { |
|
22 | + 'validate' => static function($val) { |
|
23 | 23 | return $val ? 0 : 1; |
24 | 24 | }, |
25 | 25 | 'errorCodes' => [ |
26 | 26 | 'unknownUser', |
27 | 27 | 'userIsMinor', |
28 | 28 | ], |
29 | - 'typeSetter' => static function ($type) use (&$types) { |
|
29 | + 'typeSetter' => static function($type) use (&$types) { |
|
30 | 30 | $types[$type->name] = $type; |
31 | 31 | }, |
32 | 32 | 'type' => new IDType(['name' => 'User']), |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | ); |
47 | 47 | } |
48 | 48 | |
49 | - public function testFieldsWithNoErrorCodes() |
|
49 | + public function testFieldsWithNoErrorCodes () |
|
50 | 50 | { |
51 | 51 | $types = []; |
52 | 52 | $type = new UserErrorsType([ |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ], |
60 | 60 | ], |
61 | 61 | ]), |
62 | - 'typeSetter' => static function ($type) use (&$types) { |
|
62 | + 'typeSetter' => static function($type) use (&$types) { |
|
63 | 63 | $types[$type->name] = $type; |
64 | 64 | }, |
65 | 65 | ], ['updateBook']); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | ')); |
74 | 74 | } |
75 | 75 | |
76 | - public function testFieldsWithErrorCodes() |
|
76 | + public function testFieldsWithErrorCodes () |
|
77 | 77 | { |
78 | 78 | $types = []; |
79 | 79 | new UserErrorsType([ |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 'name' => 'bookInput', |
82 | 82 | 'fields' => [ |
83 | 83 | 'authorId' => [ |
84 | - 'validate' => static function ($authorId) { |
|
84 | + 'validate' => static function($authorId) { |
|
85 | 85 | return $authorId ? 0 : 1; |
86 | 86 | }, |
87 | 87 | 'errorCodes' => ['unknownAuthor'], |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ], |
91 | 91 | ], |
92 | 92 | ]), |
93 | - 'typeSetter' => static function ($type) use (&$types) { |
|
93 | + 'typeSetter' => static function($type) use (&$types) { |
|
94 | 94 | $types[$type->name] = $type; |
95 | 95 | }, |
96 | 96 | ], ['updateBook']); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | final class ScalarTest extends TestCase |
16 | 16 | { |
17 | - public function testNoValidation() |
|
17 | + public function testNoValidation () |
|
18 | 18 | { |
19 | 19 | $type = new UserErrorsType([ |
20 | 20 | 'type' => Type::id(), |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | '), SchemaPrinter::doPrint(new Schema(['query' => $type]))); |
34 | 34 | } |
35 | 35 | |
36 | - public function testWithValidation() |
|
36 | + public function testWithValidation () |
|
37 | 37 | { |
38 | 38 | $type = new UserErrorsType([ |
39 | 39 | 'errorCodes' => ['invalidColor'], |
40 | - 'validate' => static function ($value) { |
|
40 | + 'validate' => static function($value) { |
|
41 | 41 | return $value ? 0 : 1; |
42 | 42 | }, |
43 | 43 | 'type' => new IDType(['name' => 'Color']), |