Passed
Push — master ( 257e8e...d00b29 )
by Max
04:25
created
src/Type/Definition/UserErrorsType.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                     'values' => $config['errorCodes'],
35 35
                 ]), $config),
36 36
                 'description' => 'An error code',
37
-                'resolve' => static function ($value) {
37
+                'resolve' => static function($value) {
38 38
                     return $value['error'][0] ?? null;
39 39
                 },
40 40
             ];
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
             $finalFields['msg'] = [
46 46
                 'type' => Type::string(),
47 47
                 'description' => 'A natural language description of the issue',
48
-                'resolve' => static function ($value) {
48
+                'resolve' => static function($value) {
49 49
                     return $value['error'][1] ?? null;
50 50
                 },
51 51
             ];
@@ -56,18 +56,18 @@  discard block
 block discarded – undo
56 56
             $fields = [];
57 57
             foreach ($type->getFields() as $key => $field) {
58 58
                 $newType = static::create(
59
-                    $field->config + ['typeSetter' => $config['typeSetter'] ?? null],
59
+                    $field->config+['typeSetter' => $config['typeSetter'] ?? null],
60 60
                     array_merge($path, [$key])
61 61
                 );
62 62
 
63
-                if (! $newType) {
63
+                if (!$newType) {
64 64
                     continue;
65 65
                 }
66 66
 
67 67
                 $fields[$key] = [
68 68
                     'description' => 'Error for ' . $key,
69 69
                     'type' => $newType,
70
-                    'resolve' => static function ($value) use ($key) {
70
+                    'resolve' => static function($value) use ($key) {
71 71
                         return $value[$key] ?? null;
72 72
                     },
73 73
                 ];
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                         'fields' => $fields,
85 85
                     ]), $config),
86 86
                     'description' => 'Suberrors for ' . ucfirst($path[count($path)-1]),
87
-                    'resolve' => static function (array $value) {
87
+                    'resolve' => static function(array $value) {
88 88
                         return $value['suberrors'] ?? null;
89 89
                     },
90 90
                 ];
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 $finalFields['suberrors'] = [
117 117
                     'description' => 'Suberrors for the list of ' . $type->ofType . ' items',
118 118
                     'type' => Type::listOf($newType),
119
-                    'resolve' => static function ($value) {
119
+                    'resolve' => static function($value) {
120 120
                         return $value['suberrors'] ?? null;
121 121
                     },
122 122
                 ];
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             $finalFields['index'] = [
131 131
                 'type' => Type::int(),
132 132
                 'description' => 'The index of the array item this error is paired with',
133
-                'resolve' => static function ($value) {
133
+                'resolve' => static function($value) {
134 134
                     return $value['index'];
135 135
                 },
136 136
             ];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             $config['fields']['code'] = $config['fields']['code'] ?? [
170 170
                 'type' => Type::int(),
171 171
                 'description' => 'A numeric error code. 0 on success, non-zero on failure.',
172
-                'resolve' => static function ($value) {
172
+                'resolve' => static function($value) {
173 173
                     $error = $value['error'] ?? null;
174 174
                     switch (gettype($error)) {
175 175
                         case 'integer':
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
             $config['fields']['msg'] = $config['fields']['msg'] ?? [
183 183
                 'type' => Type::string(),
184 184
                 'description' => 'An error message.',
185
-                'resolve' => static function ($value) {
185
+                'resolve' => static function($value) {
186 186
                     $error = $value['error'] ?? null;
187 187
                     switch (gettype($error)) {
188 188
                         case 'integer':
Please login to merge, or discard this patch.
src/Type/Definition/ValidatedFieldDefinition.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
         $this->typeSetter = $config['typeSetter'] ?? null;
30 30
 
31
-        if (! isset($config['type'])) {
31
+        if (!isset($config['type'])) {
32 32
             throw new Exception('You must specify a type for your field');
33 33
         }
34 34
 
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
                 'result' => [
39 39
                     'type' => $config['type'],
40 40
                     'description' => 'The payload, if any',
41
-                    'resolve' => static function ($value) {
41
+                    'resolve' => static function($value) {
42 42
                         return $value['result'] ?? null;
43 43
                     },
44 44
                 ],
45 45
                 'valid' => [
46 46
                     'type' => Type::nonNull(Type::boolean()),
47 47
                     'description' => 'Whether all validation passed. True for yes, false for no.',
48
-                    'resolve' => static function ($value) {
48
+                    'resolve' => static function($value) {
49 49
                         return $value['valid'];
50 50
                     },
51 51
                 ],
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
             'type' => $type,
63 63
             'args' => $args,
64 64
             'name' => $name,
65
-            'resolve' => function ($value, $args1, $context, $info) use ($config, $args) {
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
                 ]);
71 71
                 $errors          = $this->_validate($config, $args1);
72 72
                 $result          = $errors;
73
-                $result['valid'] = ! $errors;
73
+                $result['valid'] = !$errors;
74 74
 
75
-                if (! isset($result['error']) && ! isset($result['suberrors'])) {
75
+                if (!isset($result['error']) && !isset($result['suberrors'])) {
76 76
                     $result['result'] = $config['resolve']($value, $args1, $context, $info);
77 77
                 }
78 78
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                         $err            = $this->_validate($config, $subValue);
109 109
                     }
110 110
 
111
-                    if (! $err) {
111
+                    if (!$err) {
112 112
                         continue;
113 113
                     }
114 114
 
Please login to merge, or discard this patch.
tests/Type/ValidatedFieldDefinition/ListOfScalarValidationTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
40 40
                                 'phoneNumbers' => [
41 41
                                     'type' => 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 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
                                 // ...
Please login to merge, or discard this patch.
tests/Type/ValidatedFieldDefinition/NonNullScalarValidationTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
                         ]),
Please login to merge, or discard this patch.
tests/Type/ValidatedFieldDefinition/ScalarValidationTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
             'fields' => [
59 59
                 'title' => [
60 60
                     'type' => Type::string(),
61
-                    'resolve' => static function ($book) {
61
+                    'resolve' => static function($book) {
62 62
                         return $book['title'];
63 63
                     },
64 64
                 ],
65 65
                 'author' => [
66 66
                     'type' => $this->personType,
67
-                    'resolve' => static function ($book) {
67
+                    'resolve' => static function($book) {
68 68
                         return $book['author'];
69 69
                     },
70 70
                 ],
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             'query' => $this->query,
78 78
             'mutation' => new ObjectType([
79 79
                 'name' => 'Mutation',
80
-                'fields' => function () {
80
+                'fields' => function() {
81 81
                     return [
82 82
                         'updateBook' => new ValidatedFieldDefinition([
83 83
                             'name' => 'updateBook',
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                                 'bookId' => [
87 87
                                     'type' => Type::id(),
88 88
                                     'errorCodes' => ['bookNotFound'],
89
-                                    'validate' => function ($bookId) {
89
+                                    'validate' => function($bookId) {
90 90
                                         if (isset($this->data['books'][$bookId])) {
91 91
                                             return 0;
92 92
                                         }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                                     },
96 96
                                 ],
97 97
                             ],
98
-                            'resolve' => static function ($value, $args) : bool {
98
+                            'resolve' => static function($value, $args) : bool {
99 99
                                 return true;
100 100
                             },
101 101
                         ]),
Please login to merge, or discard this patch.
tests/Type/ValidatedFieldDefinition/ListOfInputObjectValidationTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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',
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                                     'type' => Type::listOf($this->bookAttributesInputType),
103 103
                                 ],
104 104
                             ],
105
-                            'resolve' => static function ($value, $args) : bool {
105
+                            'resolve' => static function($value, $args) : bool {
106 106
                                 // ...
107 107
                                 // do update
108 108
                                 // ...
Please login to merge, or discard this patch.
tests/Type/ValidatedFieldDefinition/InputObjectValidationTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                 'title' => [
61 61
                     'type' => Type::string(),
62 62
                     'description' => 'Enter a book title, no more than 10 characters in length',
63
-                    'validate' => static function (string $title) {
63
+                    'validate' => static function(string $title) {
64 64
                         if (strlen($title) > 10) {
65 65
                             return [1, 'book title must be less than 10 chaacters'];
66 66
                         }
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
                         'unknownAuthor',
75 75
                         'authorDeceased',
76 76
                     ],
77
-                    'validate' => function (string $authorId) {
78
-                        if (! isset($this->data['people'][$authorId])) {
77
+                    'validate' => function(string $authorId) {
78
+                        if (!isset($this->data['people'][$authorId])) {
79 79
                             return ['unknownAuthor', 'We have no record of that author'];
80 80
                         }
81 81
                         return 0;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             'query' => $this->query,
91 91
             'mutation' => new ObjectType([
92 92
                 'name' => 'Mutation',
93
-                'fields' => function () {
93
+                'fields' => function() {
94 94
                     return [
95 95
                         'updateBook' => new ValidatedFieldDefinition([
96 96
                             'name' => 'updateBook',
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                                     'type' => $this->bookAttributesInputType,
101 101
                                 ],
102 102
                             ],
103
-                            'resolve' => static function ($value, $args) : bool {
103
+                            'resolve' => static function($value, $args) : bool {
104 104
                                 // ...
105 105
                                 // do update
106 106
                                 // ...
Please login to merge, or discard this patch.
tests/Type/UserErrorsType/ListOfTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         $type = new UserErrorsType([
33 33
             'type' => Type::listOf(Type::id()),
34 34
             'errorCodes'=> ['atLeastOneRequired'],
35
-            'validation' => static function ($value) {
35
+            'validation' => static function($value) {
36 36
                 return 0;
37 37
             },
38 38
         ], ['users']);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                     ],
63 63
                 ],
64 64
             ])),
65
-            'typeSetter' => static function (Type $type) use (&$types) {
65
+            'typeSetter' => static function(Type $type) use (&$types) {
66 66
                 $types[$type->name] = $type;
67 67
             },
68 68
         ], ['bookList']);
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
             'type' => Type::listOf(Type::id()),
126 126
             'errorCodes' => ['atLeastOneRequired'],
127 127
             'suberrorCodes' => ['authorNotFound'],
128
-            'validate' => static function ($items) {
128
+            'validate' => static function($items) {
129 129
             },
130
-            'validateItem' => static function ($item) {
130
+            'validateItem' => static function($item) {
131 131
                 return 0;
132 132
             },
133
-            'typeSetter' => static function (Type $type) use (&$types) {
133
+            'typeSetter' => static function(Type $type) use (&$types) {
134 134
                 $types[$type->name] = $type;
135 135
             },
136 136
         ], ['authorList']);
Please login to merge, or discard this patch.
tests/Type/UserErrorsType/InputObjectTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
                     ],
28 28
                 ],
29 29
             ]),
30
-            'typeSetter' => static function ($type) use (&$types) {
30
+            'typeSetter' => static function($type) use (&$types) {
31 31
                 $types[$type->name] = $type;
32 32
             },
33 33
         ], ['updateBook']);
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
                     ],
59 59
                 ],
60 60
             ]),
61
-            'typeSetter' => static function ($type) use (&$types) {
61
+            'typeSetter' => static function($type) use (&$types) {
62 62
                 $types[$type->name] = $type;
63 63
             },
64 64
         ], ['updateBook']);
Please login to merge, or discard this patch.