Completed
Push — master ( cbc061...c7f3c1 )
by Alexandr
03:31
created
src/Processor.php 3 patches
Doc Comments   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -353,6 +353,9 @@  discard block
 block discarded – undo
353 353
         throw new \Exception(sprintf('Property "%s" not found in resolve result', $astField->getName()));
354 354
     }
355 355
 
356
+    /**
357
+     * @param string $path
358
+     */
356 359
     protected function getPropertyValue($data, $path)
357 360
     {
358 361
         if (is_object($data)) {
@@ -398,8 +401,8 @@  discard block
 block discarded – undo
398 401
     }
399 402
 
400 403
     /**
401
-     * @param $field     Field
402
-     * @param $query     Query
404
+     * @param Field $field     Field
405
+     * @param Query $query     Query
403 406
      *
404 407
      * @return array
405 408
      */
@@ -418,7 +421,7 @@  discard block
 block discarded – undo
418 421
     }
419 422
 
420 423
     /**
421
-     * @param $query         Query
424
+     * @param Query $query         Query
422 425
      * @param $queryType     ObjectType|TypeInterface|Field
423 426
      * @param $resolvedValue mixed
424 427
      * @param $value         array
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      */
158 158
     protected function executeMutation(Mutation $mutation, $currentLevelSchema)
159 159
     {
160
-        if (!$currentLevelSchema) throw new ConfigurationException('There is no mutation ' . $mutation->getName());
160
+        if (!$currentLevelSchema) throw new ConfigurationException('There is no mutation '.$mutation->getName());
161 161
 
162 162
         if (!$this->resolveValidator->checkFieldExist($currentLevelSchema, $mutation)) {
163 163
             return null;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
                 }
247 247
             } elseif ($field->getType()->getKind() == TypeMap::KIND_NON_NULL) {
248 248
                 if (!$field->getType()->isValidValue($preResolvedValue)) {
249
-                    $this->resolveValidator->addError(new ResolveException(sprintf('Cannot return null for non-nullable field %s', $astField->getName() . '.' . $field->getName())));
249
+                    $this->resolveValidator->addError(new ResolveException(sprintf('Cannot return null for non-nullable field %s', $astField->getName().'.'.$field->getName())));
250 250
                 } elseif (!$field->getType()->getNullableType()->isValidValue($preResolvedValue)) {
251 251
                     $this->resolveValidator->addError(new ResolveException(sprintf('Not valid value for %s field %s', $field->getType()->getNullableType()->getKind(), $field->getName())));
252 252
                     $value = null;
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
     protected function getPropertyValue($data, $path)
358 358
     {
359 359
         if (is_object($data)) {
360
-            $getter = 'get' . $this->classify($path);
360
+            $getter = 'get'.$this->classify($path);
361 361
 
362 362
             return is_callable([$data, $getter]) ? $data->$getter() : null;
363 363
         } elseif (is_array($data)) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,7 +84,9 @@  discard block
 block discarded – undo
84 84
         if (!$this->getSchema()) {
85 85
             $this->addError(new ConfigurationException('You have to set GraphQL Schema to process'));
86 86
         }
87
-        if (empty($payload) || $this->hasErrors()) return $this;
87
+        if (empty($payload) || $this->hasErrors()) {
88
+            return $this;
89
+        }
88 90
 
89 91
         $this->data = [];
90 92
 
@@ -160,7 +162,9 @@  discard block
 block discarded – undo
160 162
      */
161 163
     protected function executeMutation(Mutation $mutation, $currentLevelSchema)
162 164
     {
163
-        if (!$currentLevelSchema) throw new ConfigurationException('There is no mutation ' . $mutation->getName());
165
+        if (!$currentLevelSchema) {
166
+            throw new ConfigurationException('There is no mutation ' . $mutation->getName());
167
+        }
164 168
 
165 169
         if (!$this->resolveValidator->checkFieldExist($currentLevelSchema, $mutation)) {
166 170
             return null;
Please login to merge, or discard this patch.
src/Type/Config/Schema/SchemaConfig.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,6 @@
 block discarded – undo
11 11
 
12 12
 use Youshido\GraphQL\Type\Config\Config;
13 13
 use Youshido\GraphQL\Type\Object\AbstractObjectType;
14
-use Youshido\GraphQL\Type\Object\InputObjectType;
15 14
 use Youshido\GraphQL\Type\Object\ObjectType;
16 15
 use Youshido\GraphQL\Type\TypeMap;
17 16
 
Please login to merge, or discard this patch.
src/Type/Object/AbstractInterfaceType.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -55,6 +55,9 @@
 block discarded – undo
55 55
         return $this;
56 56
     }
57 57
 
58
+    /**
59
+     * @param AbstractObjectType $value
60
+     */
58 61
     public function isValidValue($value)
59 62
     {
60 63
         if ($value instanceof AbstractObjectType) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
     public function isValidValue($value)
59 59
     {
60 60
         if ($value instanceof AbstractObjectType) {
61
-            foreach($value->getInterfaces() as $interface) {
61
+            foreach ($value->getInterfaces() as $interface) {
62 62
                 if ($interface instanceof $this) return true;
63 63
             }
64 64
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,9 @@
 block discarded – undo
59 59
     {
60 60
         if ($value instanceof AbstractObjectType) {
61 61
             foreach($value->getInterfaces() as $interface) {
62
-                if ($interface instanceof $this) return true;
62
+                if ($interface instanceof $this) {
63
+                    return true;
64
+                }
63 65
             }
64 66
         }
65 67
         return false;
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,6 @@
 block discarded – undo
12 12
 use Youshido\GraphQL\Type\AbstractType;
13 13
 use Youshido\GraphQL\Type\Config\Object\UnionTypeConfig;
14 14
 use Youshido\GraphQL\Type\Config\Traits\ConfigCallTrait;
15
-use Youshido\GraphQL\Type\Config\TypeConfigInterface;
16 15
 use Youshido\GraphQL\Type\Traits\AutoNameTrait;
17 16
 use Youshido\GraphQL\Type\TypeMap;
18 17
 
Please login to merge, or discard this patch.
src/Validator/ConfigValidator/Rules/TypeValidationRule.php 2 patches
Unused Use Statements   -5 removed lines patch added patch discarded remove patch
@@ -11,15 +11,10 @@
 block discarded – undo
11 11
 
12 12
 use Youshido\GraphQL\Type\AbstractType;
13 13
 use Youshido\GraphQL\Type\Config\Field\FieldConfig;
14
-use Youshido\GraphQL\Type\Config\Field\InputFieldConfig;
15 14
 use Youshido\GraphQL\Type\Field\Field;
16 15
 use Youshido\GraphQL\Type\Field\InputField;
17
-use Youshido\GraphQL\Type\Object\AbstractEnumType;
18 16
 use Youshido\GraphQL\Type\Object\AbstractInputObjectType;
19
-use Youshido\GraphQL\Type\Object\AbstractInterfaceType;
20 17
 use Youshido\GraphQL\Type\Object\AbstractObjectType;
21
-use Youshido\GraphQL\Type\Object\AbstractUnionType;
22
-use Youshido\GraphQL\Type\Scalar\AbstractScalarType;
23 18
 use Youshido\GraphQL\Type\TypeMap;
24 19
 use Youshido\GraphQL\Validator\Exception\ConfigurationException;
25 20
 
Please login to merge, or discard this patch.
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -84,7 +84,9 @@  discard block
 block discarded – undo
84 84
 
85 85
     private function isArrayOfValues($data)
86 86
     {
87
-        if (!is_array($data)) return false;
87
+        if (!is_array($data)) {
88
+            return false;
89
+        }
88 90
 
89 91
         foreach ($data as $item) {
90 92
             if (!array_key_exists('value', $item)) {
@@ -97,7 +99,9 @@  discard block
 block discarded – undo
97 99
 
98 100
     private static function isArrayOfInterfaces($data)
99 101
     {
100
-        if (!is_array($data)) return false;
102
+        if (!is_array($data)) {
103
+            return false;
104
+        }
101 105
 
102 106
         foreach ($data as $item) {
103 107
             if (!TypeMap::isInterface($item)) {
@@ -110,10 +114,14 @@  discard block
 block discarded – undo
110 114
 
111 115
     private function isArrayOfFields($data)
112 116
     {
113
-        if (!is_array($data)) return false;
117
+        if (!is_array($data)) {
118
+            return false;
119
+        }
114 120
 
115 121
         foreach ($data as $name => $item) {
116
-            if (!$this->isField($item, $name)) return false;
122
+            if (!$this->isField($item, $name)) {
123
+                return false;
124
+            }
117 125
         }
118 126
 
119 127
         return true;
@@ -127,7 +135,9 @@  discard block
 block discarded – undo
127 135
 
128 136
         try {
129 137
             /** @todo need to change it to optimize performance */
130
-            if (empty($data['name'])) $data['name'] = $name;
138
+            if (empty($data['name'])) {
139
+                $data['name'] = $name;
140
+            }
131 141
 
132 142
             $config = new FieldConfig($data);
133 143
 
@@ -141,10 +151,14 @@  discard block
 block discarded – undo
141 151
 
142 152
     private function isArrayOfInputs($data)
143 153
     {
144
-        if (!is_array($data)) return false;
154
+        if (!is_array($data)) {
155
+            return false;
156
+        }
145 157
 
146 158
         foreach ($data as $name => $item) {
147
-            if (!$this->isInputField($item, $name)) return false;
159
+            if (!$this->isInputField($item, $name)) {
160
+                return false;
161
+            }
148 162
         }
149 163
 
150 164
         return true;
Please login to merge, or discard this patch.
src/Validator/SchemaValidator/SchemaValidator.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,8 @@
 block discarded – undo
51 51
     /**
52 52
      * @param Field $intField
53 53
      * @param Field $objField
54
-     * @return bool
54
+     * @param \Youshido\GraphQL\Type\Object\AbstractInterfaceType $interface
55
+     * @return boolean|null
55 56
      * @throws ConfigurationException
56 57
      */
57 58
     protected function assertFieldsIdentical($intField, $objField, $interface)
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,9 @@
 block discarded – undo
39 39
 
40 40
     protected function assertInterfaceImplementationCorrect(AbstractObjectType $type)
41 41
     {
42
-        if (!$type->getInterfaces()) return true;
42
+        if (!$type->getInterfaces()) {
43
+            return true;
44
+        }
43 45
 
44 46
         foreach ($type->getInterfaces() as $interface) {
45 47
             foreach ($interface->getConfig()->getFields() as $intField) {
Please login to merge, or discard this patch.
examples/02_blog/schema-bootstrap.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,16 +12,16 @@
 block discarded – undo
12 12
 use Youshido\GraphQL\Type\ListType\ListType;
13 13
 use Youshido\GraphQL\Type\Object\ObjectType;
14 14
 
15
-require_once __DIR__ . '/../../vendor/autoload.php';
16
-require_once __DIR__ . '/Schema/DataProvider.php';
17
-require_once __DIR__ . '/Schema/PostType.php';
18
-require_once __DIR__ . '/Schema/PostStatus.php';
19
-require_once __DIR__ . '/Schema/ContentBlockInterface.php';
20
-require_once __DIR__ . '/Schema/LikePost.php';
21
-require_once __DIR__ . '/Schema/BannerType.php';
22
-require_once __DIR__ . '/Schema/ContentBlockUnion.php';
23
-require_once __DIR__ . '/Schema/PostInputType.php';
24
-require_once __DIR__ . '/Schema/BlogSchema.php';
15
+require_once __DIR__.'/../../vendor/autoload.php';
16
+require_once __DIR__.'/Schema/DataProvider.php';
17
+require_once __DIR__.'/Schema/PostType.php';
18
+require_once __DIR__.'/Schema/PostStatus.php';
19
+require_once __DIR__.'/Schema/ContentBlockInterface.php';
20
+require_once __DIR__.'/Schema/LikePost.php';
21
+require_once __DIR__.'/Schema/BannerType.php';
22
+require_once __DIR__.'/Schema/ContentBlockUnion.php';
23
+require_once __DIR__.'/Schema/PostInputType.php';
24
+require_once __DIR__.'/Schema/BlogSchema.php';
25 25
 
26 26
 /**
27 27
 $rootQueryType = new ObjectType([
Please login to merge, or discard this patch.
examples/02_blog/router.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 use Youshido\GraphQL\Processor;
12 12
 use Youshido\GraphQL\Schema;
13 13
 
14
-require_once __DIR__ . '/schema-bootstrap.php';
14
+require_once __DIR__.'/schema-bootstrap.php';
15 15
 /** @var Schema $schema */
16 16
 $schema = new BlogSchema();
17 17
 
Please login to merge, or discard this patch.
examples/02_blog/Schema/BlogSchema.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,19 +18,19 @@
 block discarded – undo
18 18
             'latestPost'           => new PostType(),
19 19
             'randomBanner'         => [
20 20
                 'type'    => new BannerType(),
21
-                'resolve' => function () {
21
+                'resolve' => function() {
22 22
                     return DataProvider::getBanner(rand(1, 10));
23 23
                 }
24 24
             ],
25 25
             'pageContentUnion'     => [
26 26
                 'type'    => new ListType(new ContentBlockUnion()),
27
-                'resolve' => function () {
27
+                'resolve' => function() {
28 28
                     return [DataProvider::getPost(1), DataProvider::getBanner(1)];
29 29
                 }
30 30
             ],
31 31
             'pageContentInterface' => [
32 32
                 'type'    => new ListType(new ContentBlockInterface()),
33
-                'resolve' => function () {
33
+                'resolve' => function() {
34 34
                     return [DataProvider::getPost(2), DataProvider::getBanner(3)];
35 35
                 }
36 36
             ]
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,9 @@
 block discarded – undo
47 47
                     // code for creating a new post goes here
48 48
                     // we simple use our DataProvider for now
49 49
                     $post = DataProvider::getPost(10);
50
-                    if (!empty($args['post']['title'])) $post['title'] = $args['post']['title'];
50
+                    if (!empty($args['post']['title'])) {
51
+                        $post['title'] = $args['post']['title'];
52
+                    }
51 53
                     return $post;
52 54
                 }
53 55
             ]
Please login to merge, or discard this patch.
examples/02_blog/Schema/PostType.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@
 block discarded – undo
25 25
                 'args'              => [
26 26
                     'truncated' => new BooleanType()
27 27
                 ],
28
-                'resolve'           => function ($value, $args) {
29
-                    return (!empty($args['truncated'])) ? explode(' ', $value)[0] . '...' : $value;
28
+                'resolve'           => function($value, $args) {
29
+                    return (!empty($args['truncated'])) ? explode(' ', $value)[0].'...' : $value;
30 30
                 }
31 31
             ])
32 32
             ->addField('title', new NonNullType(new StringType()))
Please login to merge, or discard this patch.