@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Date: 03.12.15 |
|
| 4 | - * |
|
| 5 | - * @author Portey Vasil <[email protected]> |
|
| 6 | - */ |
|
| 3 | + * Date: 03.12.15 |
|
| 4 | + * |
|
| 5 | + * @author Portey Vasil <[email protected]> |
|
| 6 | + */ |
|
| 7 | 7 | |
| 8 | 8 | namespace Youshido\GraphQL\Definition; |
| 9 | 9 | |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Date: 04.12.15 |
|
| 4 | - * |
|
| 5 | - * @author Portey Vasil <[email protected]> |
|
| 6 | - */ |
|
| 3 | + * Date: 04.12.15 |
|
| 4 | + * |
|
| 5 | + * @author Portey Vasil <[email protected]> |
|
| 6 | + */ |
|
| 7 | 7 | |
| 8 | 8 | namespace Youshido\GraphQL\Definition\Traits; |
| 9 | 9 | |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Date: 04.12.15 |
|
| 4 | - * |
|
| 5 | - * @author Portey Vasil <[email protected]> |
|
| 6 | - */ |
|
| 3 | + * Date: 04.12.15 |
|
| 4 | + * |
|
| 5 | + * @author Portey Vasil <[email protected]> |
|
| 6 | + */ |
|
| 7 | 7 | |
| 8 | 8 | namespace Youshido\GraphQL\Definition\Traits; |
| 9 | 9 | |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Date: 20.11.15 |
|
| 4 | - * |
|
| 5 | - * @author Portey Vasil <[email protected]> |
|
| 6 | - */ |
|
| 3 | + * Date: 20.11.15 |
|
| 4 | + * |
|
| 5 | + * @author Portey Vasil <[email protected]> |
|
| 6 | + */ |
|
| 7 | 7 | |
| 8 | 8 | namespace Youshido\GraphQL\Parser\Ast; |
| 9 | 9 | |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | - * @return Field[]|Query[] |
|
| 64 | + * @return Query[] |
|
| 65 | 65 | */ |
| 66 | 66 | public function getFields() |
| 67 | 67 | { |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Date: 03.12.15 |
|
| 4 | - * |
|
| 5 | - * @author Portey Vasil <[email protected]> |
|
| 6 | - */ |
|
| 3 | + * Date: 03.12.15 |
|
| 4 | + * |
|
| 5 | + * @author Portey Vasil <[email protected]> |
|
| 6 | + */ |
|
| 7 | 7 | |
| 8 | 8 | namespace Youshido\GraphQL\Definition; |
| 9 | 9 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | /** |
| 190 | 190 | * @param $objectType InputObjectType|ObjectType |
| 191 | 191 | * @param $query Mutation|Query |
| 192 | - * @return null |
|
| 192 | + * @return boolean |
|
| 193 | 193 | */ |
| 194 | 194 | private function checkFieldExist($objectType, $query) |
| 195 | 195 | { |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
| 229 | - * @param $field Field |
|
| 229 | + * @param Field $field Field |
|
| 230 | 230 | * @param $contextValue mixed |
| 231 | 231 | * @param $query Query |
| 232 | 232 | * |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $preResolvedValue = $this->getPreResolvedValue($contextValue, $query); |
| 154 | 154 | |
| 155 | 155 | if ($field->getConfig()->getType()->getKind() == TypeMap::KIND_LIST) { |
| 156 | - if(!is_array($preResolvedValue)){ |
|
| 156 | + if (!is_array($preResolvedValue)) { |
|
| 157 | 157 | $value = null; |
| 158 | 158 | $this->resolveValidator->addError(new ResolveException('Not valid resolve value for list type')); |
| 159 | 159 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | if ($type->getKind() == TypeMap::KIND_ENUM) { |
| 168 | 168 | /** @var $type AbstractEnumType */ |
| 169 | - if(!$type->isValidValue($resolvedValueItem)) { |
|
| 169 | + if (!$type->isValidValue($resolvedValueItem)) { |
|
| 170 | 170 | $this->resolveValidator->addError(new ResolveException('Not valid value for enum type')); |
| 171 | 171 | |
| 172 | 172 | $listValue = null; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $value = $listValue; |
| 184 | 184 | } else { |
| 185 | 185 | if ($field->getType()->getKind() == TypeMap::KIND_ENUM) { |
| 186 | - if(!$field->getType()->isValidValue($preResolvedValue)) { |
|
| 186 | + if (!$field->getType()->isValidValue($preResolvedValue)) { |
|
| 187 | 187 | $this->resolveValidator->addError(new ResolveException('Not valid value for enum type')); |
| 188 | 188 | $value = null; |
| 189 | 189 | } else { |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | $value[] = []; |
| 215 | 215 | $index = count($value) - 1; |
| 216 | 216 | |
| 217 | - if(in_array($field->getConfig()->getType()->getConfig()->getItem()->getKind(), [TypeMap::KIND_UNION, TypeMap::KIND_INTERFACE]) ) { |
|
| 217 | + if (in_array($field->getConfig()->getType()->getConfig()->getItem()->getKind(), [TypeMap::KIND_UNION, TypeMap::KIND_INTERFACE])) { |
|
| 218 | 218 | $type = $field->getConfig()->getType()->getConfig()->getItemConfig()->resolveType($resolvedValueItem); |
| 219 | 219 | } else { |
| 220 | 220 | $type = $field->getType(); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | { |
| 284 | 284 | $resolvedValue = $field->getConfig()->resolve($contextValue, $this->parseArgumentsValues($field, $query)); |
| 285 | 285 | |
| 286 | - if(in_array($field->getType()->getKind(), [TypeMap::KIND_UNION, TypeMap::KIND_INTERFACE])){ |
|
| 286 | + if (in_array($field->getType()->getKind(), [TypeMap::KIND_UNION, TypeMap::KIND_INTERFACE])) { |
|
| 287 | 287 | $resolvedType = $field->getType()->resolveType($resolvedValue); |
| 288 | 288 | $field->setType($resolvedType); |
| 289 | 289 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | return []; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - $args = []; |
|
| 306 | + $args = []; |
|
| 307 | 307 | foreach ($query->getArguments() as $argument) { |
| 308 | 308 | $args[$argument->getName()] = $field->getConfig()->getArgument($argument->getName())->getType()->parseValue($argument->getValue()->getValue()); |
| 309 | 309 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | foreach ($fragment->getFields() as $fragmentField) { |
| 337 | 337 | $value = $this->collectValue($value, $this->executeQuery($fragmentField, $queryType, $resolvedValue)); |
| 338 | 338 | } |
| 339 | - } else if($field->getName() == self::TYPE_NAME_QUERY) { |
|
| 339 | + } else if ($field->getName() == self::TYPE_NAME_QUERY) { |
|
| 340 | 340 | $value = $this->collectValue($value, [$field->getAlias() ?: $field->getName() => $queryType->getName()]); |
| 341 | 341 | } else { |
| 342 | 342 | $value = $this->collectValue($value, $this->executeQuery($field, $queryType, $resolvedValue)); |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | public function addFields($fieldsArray) |
| 42 | 42 | { |
| 43 | - foreach($fieldsArray as $fieldName => $fieldConfig) { |
|
| 43 | + foreach ($fieldsArray as $fieldName => $fieldConfig) { |
|
| 44 | 44 | if (is_object($fieldConfig)) { |
| 45 | 45 | $this->addField($fieldName, $fieldConfig); |
| 46 | 46 | } else { |
@@ -79,7 +79,9 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | private function isArrayOfValues($data) |
| 81 | 81 | { |
| 82 | - if (!is_array($data)) return false; |
|
| 82 | + if (!is_array($data)) { |
|
| 83 | + return false; |
|
| 84 | + } |
|
| 83 | 85 | |
| 84 | 86 | foreach ($data as $item) { |
| 85 | 87 | if (!array_key_exists('value', $item)) { |
@@ -92,10 +94,14 @@ discard block |
||
| 92 | 94 | |
| 93 | 95 | private function isArrayOfFields($data) |
| 94 | 96 | { |
| 95 | - if (!is_array($data)) return false; |
|
| 97 | + if (!is_array($data)) { |
|
| 98 | + return false; |
|
| 99 | + } |
|
| 96 | 100 | |
| 97 | 101 | foreach ($data as $name => $item) { |
| 98 | - if (!$this->isField($item, $name)) return false; |
|
| 102 | + if (!$this->isField($item, $name)) { |
|
| 103 | + return false; |
|
| 104 | + } |
|
| 99 | 105 | } |
| 100 | 106 | |
| 101 | 107 | return true; |
@@ -109,7 +115,9 @@ discard block |
||
| 109 | 115 | |
| 110 | 116 | try { |
| 111 | 117 | /** @todo need to change it to optimize performance */ |
| 112 | - if (empty($data['name'])) $data['name'] = $name; |
|
| 118 | + if (empty($data['name'])) { |
|
| 119 | + $data['name'] = $name; |
|
| 120 | + } |
|
| 113 | 121 | |
| 114 | 122 | $config = new FieldConfig($data); |
| 115 | 123 | |
@@ -123,10 +131,14 @@ discard block |
||
| 123 | 131 | |
| 124 | 132 | private function isArrayOfInputs($data) |
| 125 | 133 | { |
| 126 | - if (!is_array($data)) return false; |
|
| 134 | + if (!is_array($data)) { |
|
| 135 | + return false; |
|
| 136 | + } |
|
| 127 | 137 | |
| 128 | 138 | foreach ($data as $name => $item) { |
| 129 | - if (!$this->isInputField($item, $name)) return false; |
|
| 139 | + if (!$this->isInputField($item, $name)) { |
|
| 140 | + return false; |
|
| 141 | + } |
|
| 130 | 142 | } |
| 131 | 143 | |
| 132 | 144 | return true; |
@@ -139,7 +151,9 @@ discard block |
||
| 139 | 151 | } |
| 140 | 152 | try { |
| 141 | 153 | /** @todo need to change it to optimize performance */ |
| 142 | - if (empty($data['name'])) $data['name'] = $name; |
|
| 154 | + if (empty($data['name'])) { |
|
| 155 | + $data['name'] = $name; |
|
| 156 | + } |
|
| 143 | 157 | |
| 144 | 158 | $config = new InputFieldConfig($data); |
| 145 | 159 | |