@@ -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 = []; |
@@ -15,18 +15,18 @@ discard block |
||
15 | 15 | |
16 | 16 | final class ErrorCodeTypeGenerationTest extends TestCase |
17 | 17 | { |
18 | - public function testMultipleErrorCodesOnSelf(): void |
|
18 | + public function testMultipleErrorCodesOnSelf (): void |
|
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): void { |
|
29 | + 'typeSetter' => static function($type) use (&$types): void { |
|
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(): void |
|
49 | + public function testFieldsWithNoErrorCodes (): void |
|
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): void { |
|
62 | + 'typeSetter' => static function($type) use (&$types): void { |
|
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(): void |
|
76 | + public function testFieldsWithErrorCodes (): void |
|
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): void { |
|
93 | + 'typeSetter' => static function($type) use (&$types): void { |
|
94 | 94 | $types[$type->name] = $type; |
95 | 95 | }, |
96 | 96 | ], ['updateBook']); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | final class ListOfTest extends TestCase |
17 | 17 | { |
18 | - public function testScalarTypeWithNoValidation(): void |
|
18 | + public function testScalarTypeWithNoValidation (): void |
|
19 | 19 | { |
20 | 20 | $type = new UserErrorsType([ |
21 | 21 | 'type' => Type::listOf(Type::id()), |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | '), SchemaPrinter::doPrint(new Schema(['query' => $type]))); |
35 | 35 | } |
36 | 36 | |
37 | - public function testListOfScalarWithValidationOnSelf(): void |
|
37 | + public function testListOfScalarWithValidationOnSelf (): void |
|
38 | 38 | { |
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']); |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | '), SchemaPrinter::doPrint(new Schema(['query' => $type]))); |
67 | 67 | } |
68 | 68 | |
69 | - public function testListOfListOfListOfScalarWithValidationOnSelfAndWrappedType(): void |
|
69 | + public function testListOfListOfListOfScalarWithValidationOnSelfAndWrappedType (): void |
|
70 | 70 | { |
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']); |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | '), SchemaPrinter::doPrint(new Schema(['query' => $type]))); |
117 | 117 | } |
118 | 118 | |
119 | - public function testListOfInputObjectWithValidationOnSelf(): void |
|
119 | + public function testListOfInputObjectWithValidationOnSelf (): void |
|
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 | } |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | '), SchemaPrinter::doPrint(new Schema(['query' => $type]))); |
161 | 161 | } |
162 | 162 | |
163 | - public function testListOfInputObjectWithValidationOnWrappedSelf(): void |
|
163 | + public function testListOfInputObjectWithValidationOnWrappedSelf (): void |
|
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 | ], |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | final class ScalarTest extends TestCase |
16 | 16 | { |
17 | - public function testNoValidation(): void |
|
17 | + public function testNoValidation (): void |
|
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(): void |
|
36 | + public function testWithValidation (): void |
|
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']), |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | final class BasicTest extends TestCase |
15 | 15 | { |
16 | - public function testNoValidationOnSelf(): void |
|
16 | + public function testNoValidationOnSelf (): void |
|
17 | 17 | { |
18 | 18 | $type = new UserErrorsType([ |
19 | 19 | 'type' => Type::id(), |
@@ -32,20 +32,20 @@ discard block |
||
32 | 32 | '), SchemaPrinter::doPrint(new Schema(['query' => $type]))); |
33 | 33 | } |
34 | 34 | |
35 | - public function testNoType(): void |
|
35 | + public function testNoType (): void |
|
36 | 36 | { |
37 | 37 | $this->expectExceptionMessage('You must specify a type for your field'); |
38 | 38 | UserErrorsType::create([ |
39 | - 'validate' => static function ($value) { |
|
39 | + 'validate' => static function($value) { |
|
40 | 40 | return $value ? 0 : 1; |
41 | 41 | }, |
42 | 42 | ], ['upsertSku']); |
43 | 43 | } |
44 | 44 | |
45 | - public function testValidationWithNoErrorCodes(): void |
|
45 | + public function testValidationWithNoErrorCodes (): void |
|
46 | 46 | { |
47 | 47 | $type = UserErrorsType::create([ |
48 | - 'validate' => static function ($value) { |
|
48 | + 'validate' => static function($value) { |
|
49 | 49 | return $value ? 0 : 1; |
50 | 50 | }, |
51 | 51 | 'type' => Type::id(), |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | final class InputObjectTest extends TestCase |
17 | 17 | { |
18 | - public function testFieldsWithNoErrorCodes(): void |
|
18 | + public function testFieldsWithNoErrorCodes (): void |
|
19 | 19 | { |
20 | 20 | $type = new UserErrorsType([ |
21 | 21 | 'type' => new InputObjectType([ |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | ); |
46 | 46 | } |
47 | 47 | |
48 | - public function testFieldsWithErrorCodesButNoValidate(): void |
|
48 | + public function testFieldsWithErrorCodesButNoValidate (): void |
|
49 | 49 | { |
50 | 50 | $this->expectExceptionMessage('If you specify errorCodes, you must also provide a validate callback'); |
51 | 51 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ], ['updateBook']); |
64 | 64 | } |
65 | 65 | |
66 | - public function testFieldsWithValidate(): void |
|
66 | + public function testFieldsWithValidate (): void |
|
67 | 67 | { |
68 | 68 | $type = new UserErrorsType([ |
69 | 69 | 'type' => new InputObjectType([ |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'fields' => [ |
72 | 72 | 'authorId' => [ |
73 | 73 | 'errorCodes' => ['unknownAuthor'], |
74 | - 'validate' => static function (int $authorId) { |
|
74 | + 'validate' => static function(int $authorId) { |
|
75 | 75 | return $authorId ? 0 : 1; |
76 | 76 | }, |
77 | 77 | 'type' => Type::id(), |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** @var Schema */ |
37 | 37 | protected $schema; |
38 | 38 | |
39 | - protected function setUp(): void |
|
39 | + protected function setUp (): void |
|
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(): void |
|
102 | + public function testNonNullScalarValidationSuccess (): void |
|
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() : void |
|
132 | + public function testNonNullScalarValidationFail () : void |
|
133 | 133 | { |
134 | 134 | $res = GraphQL::executeQuery( |
135 | 135 | $this->schema, |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | final class BasicTest extends TestCase |
11 | 11 | { |
12 | - public function testInferName(): void |
|
12 | + public function testInferName (): void |
|
13 | 13 | { |
14 | 14 | $def = new NamelessDef([ |
15 | 15 | 'type' => Type::boolean(), |
@@ -17,12 +17,12 @@ 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 { |
|
25 | + 'resolve' => static function($value) : bool { |
|
26 | 26 | return !!$value; |
27 | 27 | }, |
28 | 28 | ]); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | static::assertEquals('namelessDef', $def->name); |
31 | 31 | } |
32 | 32 | |
33 | - public function testInferNameNameAlreadyExists(): void |
|
33 | + public function testInferNameNameAlreadyExists (): void |
|
34 | 34 | { |
35 | 35 | $def = new NamelessDef([ |
36 | 36 | 'name' => 'FooDef', |
@@ -39,12 +39,12 @@ 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 { |
|
47 | + 'resolve' => static function($value) : bool { |
|
48 | 48 | return !!$value; |
49 | 49 | }, |
50 | 50 | ]); |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | /** @var Schema */ |
25 | 25 | protected $schema; |
26 | 26 | |
27 | - protected function setUp(): void |
|
27 | + protected function setUp (): void |
|
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(): void |
|
66 | + public function testItemsValidationOnWrappedTypeFail (): void |
|
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(): void |
|
123 | + public function testItemsValidationOnSelfFail (): void |
|
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(): void |
|
175 | + public function testListOfValidationFail (): void |
|
176 | 176 | { |
177 | 177 | $res = GraphQL::executeQuery( |
178 | 178 | $this->schema, |