Failed Conditions
Push — master ( 140623...fb5c25 )
by Max
07:43 queued 56s
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.
examples/02-custom-error-codes/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
                         }
73 73
                     ],
74 74
                 ],
75
-                'resolve' => function ($value, $args) use ($authors) {
75
+                'resolve' => function($value, $args) use ($authors) {
76 76
                     $authorId = $args['authorId'];
77 77
 
78 78
                     // AuthorProvider::update($authorId);
Please login to merge, or discard this patch.
examples/01-basic-scalar-validation/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
                         }
63 63
                     ],
64 64
                 ],
65
-                'resolve' => function ($value, $args) use ($authors) {
65
+                'resolve' => function($value, $args) use ($authors) {
66 66
                     // do your operation on the author
67 67
                     // AuthorProvider::update($authorId);
68 68
                     return $authors[$args['authorId']];
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.
examples/04-list-of-validation/index.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@
 block discarded – undo
30 30
                         ],
31 31
                         'validateItem' => function(string $phoneNumber) {
32 32
                             $res = preg_match('/^[0-9\-]+$/', $phoneNumber) === 1;
33
-                            return ! $res ? ['invalidPhoneNumber', 'That does not seem to be a valid phone number'] : 0;
33
+                            return !$res ? ['invalidPhoneNumber', 'That does not seem to be a valid phone number'] : 0;
34 34
                         },
35 35
                         'type' => Type::listOf(Type::string())
36 36
                     ]
37 37
                 ],
38
-                'resolve' => function ($value, $args) {
38
+                'resolve' => function($value, $args) {
39 39
                     // PhoneNumberProvider::setPhoneNumbers($args['phoneNumbers']);
40 40
                     return true;
41 41
                 },
Please login to merge, or discard this patch.
examples/03-input-object-validation/index.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
                     'validate' => function(string $name) {
59 59
                         global $authors;
60 60
 
61
-                        if(strlen($name) > 15) {
61
+                        if (strlen($name) > 15) {
62 62
                             return ['nameTooLong', "Name is too long; please keep it under 15 characters."];
63 63
                         }
64 64
 
65
-                        if(array_search($name, array_column($authors, "name")) !== false) {
65
+                        if (array_search($name, array_column($authors, "name")) !== false) {
66 66
                             return ['nameNotUnique', 'That name is already in use'];
67 67
                         }
68 68
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                         'invalidAge'
76 76
                     ],
77 77
                     'validate' => function(int $age) {
78
-                        if($age <= 0) {
78
+                        if ($age <= 0) {
79 79
                             return ['invalidAge', "Invalid Age; must be positive"];
80 80
                         }
81 81
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                         'type' => new AuthorAttributes()
116 116
                     ]
117 117
                 ],
118
-                'resolve' => function ($value, $args) use ($authors) {
118
+                'resolve' => function($value, $args) use ($authors) {
119 119
                     $authorId = $args['authorId'];
120 120
 
121 121
                     // AuthorProvider::update($authorId, $args['attributes']);
Please login to merge, or discard this patch.