Passed
Pull Request — master (#1)
by Max
04:22
created
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/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/BasicTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
     public function testValidationWithNoErrorCodes()
49 49
     {
50 50
         $type = UserErrorsType::create([
51
-            'validate' => static function ($value) {
51
+            'validate' => static function($value) {
52 52
             },
53 53
             'type' => Type::id(),
54 54
         ], ['upsertSku']);
Please login to merge, or discard this patch.
tests/Type/ErrorCodeTypeGenerationTest.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
                 'unknownUser',
24 24
                 'userIsMinor',
25 25
             ],
26
-            'typeSetter' => static function ($type) use (&$types) {
26
+            'typeSetter' => static function($type) use (&$types) {
27 27
                 $types[$type->name] = $type;
28 28
             },
29 29
             'type' => new IDType(['name' => 'User']),
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                     ],
57 57
                 ],
58 58
             ]),
59
-            'typeSetter' => static function ($type) use (&$types) {
59
+            'typeSetter' => static function($type) use (&$types) {
60 60
                 $types[$type->name] = $type;
61 61
             },
62 62
         ], ['updateBook']);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                     ],
85 85
                 ],
86 86
             ]),
87
-            'typeSetter' => static function ($type) use (&$types) {
87
+            'typeSetter' => static function($type) use (&$types) {
88 88
                 $types[$type->name] = $type;
89 89
             },
90 90
         ], ['updateBook']);
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     {
20 20
         $types = [];
21 21
         new UserErrorsType([
22
-        	'validate' => static function($val) {},
22
+            'validate' => static function($val) {},
23 23
             'errorCodes' => [
24 24
                 'unknownUser',
25 25
                 'userIsMinor',
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 'name' => 'bookInput',
80 80
                 'fields' => [
81 81
                     'authorId' => [
82
-	                    'validate' => static function($authorId) {},
82
+                        'validate' => static function($authorId) {},
83 83
                         'errorCodes' => ['unknownAuthor'],
84 84
                         'type' => Type::id(),
85 85
                         'description' => 'An author Id',
Please login to merge, or discard this patch.
src/Type/Definition/UserErrorsType.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -26,33 +26,33 @@
 block discarded – undo
26 26
         GraphQL\Utils\Utils::invariant($config['type'] instanceof Type, 'Must provide type.');
27 27
 
28 28
         if (isset($config['errorCodes'])) {
29
-        	if(isset($config['validate'])) {
30
-		        /** code property */
31
-		        $finalFields['code'] = [
32
-			        'type' => $this->_set(new EnumType([
33
-				        'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode',
34
-				        'description' => 'Error code',
35
-				        'values' => $config['errorCodes'],
36
-			        ]), $config),
37
-			        'description' => 'An error code',
38
-			        'resolve' => static function ($value) {
39
-				        return $value['error'][0] ?? null;
40
-			        },
41
-		        ];
42
-
43
-		        /**
44
-		         * msg property
45
-		         */
46
-		        $finalFields['msg'] = [
47
-			        'type' => Type::string(),
48
-			        'description' => 'A natural language description of the issue',
49
-			        'resolve' => static function ($value) {
50
-				        return $value['error'][1] ?? null;
51
-			        },
52
-		        ];
53
-	        } else {
54
-        		throw new \Exception("If you specify errorCodes, you must also provide a validate callback");
55
-	        }
29
+            if(isset($config['validate'])) {
30
+                /** code property */
31
+                $finalFields['code'] = [
32
+                    'type' => $this->_set(new EnumType([
33
+                        'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode',
34
+                        'description' => 'Error code',
35
+                        'values' => $config['errorCodes'],
36
+                    ]), $config),
37
+                    'description' => 'An error code',
38
+                    'resolve' => static function ($value) {
39
+                        return $value['error'][0] ?? null;
40
+                    },
41
+                ];
42
+
43
+                /**
44
+                 * msg property
45
+                 */
46
+                $finalFields['msg'] = [
47
+                    'type' => Type::string(),
48
+                    'description' => 'A natural language description of the issue',
49
+                    'resolve' => static function ($value) {
50
+                        return $value['error'][1] ?? null;
51
+                    },
52
+                ];
53
+            } else {
54
+                throw new \Exception("If you specify errorCodes, you must also provide a validate callback");
55
+            }
56 56
         }
57 57
 
58 58
         $type = $config['type'];
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         GraphQL\Utils\Utils::invariant($config['type'] instanceof Type, 'Must provide type.');
27 27
 
28 28
         if (isset($config['errorCodes'])) {
29
-        	if(isset($config['validate'])) {
29
+        	if (isset($config['validate'])) {
30 30
 		        /** code property */
31 31
 		        $finalFields['code'] = [
32 32
 			        'type' => $this->_set(new EnumType([
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 				        'values' => $config['errorCodes'],
36 36
 			        ]), $config),
37 37
 			        'description' => 'An error code',
38
-			        'resolve' => static function ($value) {
38
+			        'resolve' => static function($value) {
39 39
 				        return $value['error'][0] ?? null;
40 40
 			        },
41 41
 		        ];
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		        $finalFields['msg'] = [
47 47
 			        'type' => Type::string(),
48 48
 			        'description' => 'A natural language description of the issue',
49
-			        'resolve' => static function ($value) {
49
+			        'resolve' => static function($value) {
50 50
 				        return $value['error'][1] ?? null;
51 51
 			        },
52 52
 		        ];
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
             $fields = [];
61 61
             foreach ($type->getFields() as $key => $field) {
62 62
                 $newType = static::create(
63
-                    $field->config + ['typeSetter' => $config['typeSetter'] ?? null],
63
+                    $field->config+['typeSetter' => $config['typeSetter'] ?? null],
64 64
                     array_merge($path, [$key])
65 65
                 );
66 66
 
67
-                if (! $newType) {
67
+                if (!$newType) {
68 68
                     continue;
69 69
                 }
70 70
 
71 71
                 $fields[$key] = [
72 72
                     'description' => 'Error for ' . $key,
73 73
                     'type' => $newType,
74
-                    'resolve' => static function ($value) use ($key) {
74
+                    'resolve' => static function($value) use ($key) {
75 75
                         return $value[$key] ?? null;
76 76
                     },
77 77
                 ];
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                         'fields' => $fields,
89 89
                     ]), $config),
90 90
                     'description' => 'Suberrors for ' . ucfirst($path[count($path)-1]),
91
-                    'resolve' => static function (array $value) {
91
+                    'resolve' => static function(array $value) {
92 92
                         return $value['suberrors'] ?? null;
93 93
                     },
94 94
                 ];
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                 $finalFields['suberrors'] = [
113 113
                     'description' => 'Suberrors for the list of ' . $type->ofType . ' items',
114 114
                     'type' => $newType,
115
-                    'resolve' => static function ($value) {
115
+                    'resolve' => static function($value) {
116 116
                         return $value['suberrors'] ?? null;
117 117
                     },
118 118
                 ];
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             $finalFields['path'] = [
127 127
                 'type' => Type::listOf(Type::int()),
128 128
                 'description' => 'A path describing this items\'s location in the nested array',
129
-                'resolve' => static function ($value) {
129
+                'resolve' => static function($value) {
130 130
                     return $value['path'];
131 131
                 },
132 132
             ];
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             $config['fields']['code'] = $config['fields']['code'] ?? [
164 164
                 'type' => Type::int(),
165 165
                 'description' => 'A numeric error code. 0 on success, non-zero on failure.',
166
-                'resolve' => static function ($value) {
166
+                'resolve' => static function($value) {
167 167
                     $error = $value['error'] ?? null;
168 168
                     switch (gettype($error)) {
169 169
                         case 'integer':
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             $config['fields']['msg'] = $config['fields']['msg'] ?? [
177 177
                 'type' => Type::string(),
178 178
                 'description' => 'An error message.',
179
-                'resolve' => static function ($value) {
179
+                'resolve' => static function($value) {
180 180
                     $error = $value['error'] ?? null;
181 181
                     switch (gettype($error)) {
182 182
                         case 'integer':
Please login to merge, or discard this patch.
tests/Utils.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
         }
23 23
 
24 24
         // Toss out the first and last lines.
25
-        $lines = array_slice($lines, 1, count($lines) - 2);
25
+        $lines = array_slice($lines, 1, count($lines)-2);
26 26
 
27 27
         // take the tabs from the first line, and subtract them from all lines
28 28
         $matches = [];
Please login to merge, or discard this patch.
tests/Type/UserErrorsType/InputObjectTest.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function testFieldsWithErrorCodesButNoValidate()
47 47
     {
48
-	    $this->expectExceptionMessage("If you specify errorCodes, you must also provide a validate callback");
48
+        $this->expectExceptionMessage("If you specify errorCodes, you must also provide a validate callback");
49 49
 
50
-	    $type  = new UserErrorsType([
50
+        $type  = new UserErrorsType([
51 51
             'type' => new InputObjectType([
52 52
                 'name' => 'bookInput',
53 53
                 'fields' => [
@@ -61,25 +61,25 @@  discard block
 block discarded – undo
61 61
         ], ['updateBook']);
62 62
     }
63 63
 
64
-	public function testFieldsWithValidate()
65
-	{
66
-		$type  = new UserErrorsType([
67
-			'type' => new InputObjectType([
68
-				'name' => 'bookInput',
69
-				'fields' => [
70
-					'authorId' => [
71
-						'errorCodes' => ['unknownAuthor'],
72
-						'validate' => static function(int $authorId) {
64
+    public function testFieldsWithValidate()
65
+    {
66
+        $type  = new UserErrorsType([
67
+            'type' => new InputObjectType([
68
+                'name' => 'bookInput',
69
+                'fields' => [
70
+                    'authorId' => [
71
+                        'errorCodes' => ['unknownAuthor'],
72
+                        'validate' => static function(int $authorId) {
73 73
 
74
-						},
75
-						'type' => Type::id(),
76
-						'description' => 'An author Id',
77
-					],
78
-				],
79
-			])
80
-		], ['updateBook']);
74
+                        },
75
+                        'type' => Type::id(),
76
+                        'description' => 'An author Id',
77
+                    ],
78
+                ],
79
+            ])
80
+        ], ['updateBook']);
81 81
 
82
-		self::assertEquals(Utils::nowdoc('
82
+        self::assertEquals(Utils::nowdoc('
83 83
 			schema {
84 84
 			  query: UpdateBookError
85 85
 			}
@@ -111,5 +111,5 @@  discard block
 block discarded – undo
111 111
 			}
112 112
 
113 113
 		'), SchemaPrinter::doPrint(new Schema(['query' => $type])));
114
-	}
114
+    }
115 115
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 {
18 18
     public function testFieldsWithNoErrorCodes()
19 19
     {
20
-        $type  = new UserErrorsType([
20
+        $type = new UserErrorsType([
21 21
             'type' => new InputObjectType([
22 22
                 'name' => 'bookInput',
23 23
                 'fields' => [
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     {
48 48
 	    $this->expectExceptionMessage("If you specify errorCodes, you must also provide a validate callback");
49 49
 
50
-	    $type  = new UserErrorsType([
50
+	    $type = new UserErrorsType([
51 51
             'type' => new InputObjectType([
52 52
                 'name' => 'bookInput',
53 53
                 'fields' => [
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
 	public function testFieldsWithValidate()
65 65
 	{
66
-		$type  = new UserErrorsType([
66
+		$type = new UserErrorsType([
67 67
 			'type' => new InputObjectType([
68 68
 				'name' => 'bookInput',
69 69
 				'fields' => [
Please login to merge, or discard this patch.
tests/Type/UserErrorsType/ScalarTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
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']),
Please login to merge, or discard this patch.