@@ -299,19 +299,19 @@ discard block |
||
299 | 299 | // field and its descendants will be omitted, and sibling fields will still |
300 | 300 | // be executed. An execution which encounters errors will still result in a |
301 | 301 | // resolved Promise. |
302 | - $result = $this->exeContext->promises->create(function (callable $resolve) { |
|
302 | + $result = $this->exeContext->promises->create(function(callable $resolve) { |
|
303 | 303 | return $resolve($this->executeOperation($this->exeContext->operation, $this->exeContext->rootValue)); |
304 | 304 | }); |
305 | 305 | return $result |
306 | - ->then(null, function ($error) { |
|
306 | + ->then(null, function($error) { |
|
307 | 307 | // Errors from sub-fields of a NonNull type may propagate to the top level, |
308 | 308 | // at which point we still log the error and null the parent field, which |
309 | 309 | // in this case is the entire response. |
310 | 310 | $this->exeContext->addError($error); |
311 | 311 | return null; |
312 | 312 | }) |
313 | - ->then(function ($data) { |
|
314 | - if ($data !== null){ |
|
313 | + ->then(function($data) { |
|
314 | + if ($data !== null) { |
|
315 | 315 | $data = (array) $data; |
316 | 316 | } |
317 | 317 | return new ExecutionResult($data, $this->exeContext->errors); |
@@ -339,8 +339,7 @@ discard block |
||
339 | 339 | // Similar to completeValueCatchingError. |
340 | 340 | try { |
341 | 341 | $result = $operation->operation === 'mutation' ? |
342 | - $this->executeFieldsSerially($type, $rootValue, $path, $fields) : |
|
343 | - $this->executeFields($type, $rootValue, $path, $fields); |
|
342 | + $this->executeFieldsSerially($type, $rootValue, $path, $fields) : $this->executeFields($type, $rootValue, $path, $fields); |
|
344 | 343 | |
345 | 344 | $promise = $this->getPromise($result); |
346 | 345 | if ($promise) { |
@@ -391,7 +390,7 @@ discard block |
||
391 | 390 | if (!$subscriptionType) { |
392 | 391 | throw new Error( |
393 | 392 | 'Schema is not configured for subscriptions.', |
394 | - [ $operation ] |
|
393 | + [$operation] |
|
395 | 394 | ); |
396 | 395 | } |
397 | 396 | return $subscriptionType; |
@@ -417,7 +416,7 @@ discard block |
||
417 | 416 | { |
418 | 417 | $prevPromise = $this->exeContext->promises->createFulfilled([]); |
419 | 418 | |
420 | - $process = function ($results, $responseName, $path, $parentType, $sourceValue, $fieldNodes) { |
|
419 | + $process = function($results, $responseName, $path, $parentType, $sourceValue, $fieldNodes) { |
|
421 | 420 | $fieldPath = $path; |
422 | 421 | $fieldPath[] = $responseName; |
423 | 422 | $result = $this->resolveField($parentType, $sourceValue, $fieldNodes, $fieldPath); |
@@ -426,7 +425,7 @@ discard block |
||
426 | 425 | } |
427 | 426 | $promise = $this->getPromise($result); |
428 | 427 | if ($promise) { |
429 | - return $promise->then(function ($resolvedResult) use ($responseName, $results) { |
|
428 | + return $promise->then(function($resolvedResult) use ($responseName, $results) { |
|
430 | 429 | $results[$responseName] = $resolvedResult; |
431 | 430 | return $results; |
432 | 431 | }); |
@@ -436,12 +435,12 @@ discard block |
||
436 | 435 | }; |
437 | 436 | |
438 | 437 | foreach ($fields as $responseName => $fieldNodes) { |
439 | - $prevPromise = $prevPromise->then(function ($resolvedResults) use ($process, $responseName, $path, $parentType, $sourceValue, $fieldNodes) { |
|
438 | + $prevPromise = $prevPromise->then(function($resolvedResults) use ($process, $responseName, $path, $parentType, $sourceValue, $fieldNodes) { |
|
440 | 439 | return $process($resolvedResults, $responseName, $path, $parentType, $sourceValue, $fieldNodes); |
441 | 440 | }); |
442 | 441 | } |
443 | 442 | |
444 | - return $prevPromise->then(function ($resolvedResults) { |
|
443 | + return $prevPromise->then(function($resolvedResults) { |
|
445 | 444 | return self::fixResultsIfEmptyArray($resolvedResults); |
446 | 445 | }); |
447 | 446 | } |
@@ -826,7 +825,7 @@ discard block |
||
826 | 825 | |
827 | 826 | $promise = $this->getPromise($completed); |
828 | 827 | if ($promise) { |
829 | - return $promise->then(null, function ($error) use ($exeContext) { |
|
828 | + return $promise->then(null, function($error) use ($exeContext) { |
|
830 | 829 | $exeContext->addError($error); |
831 | 830 | return $this->exeContext->promises->createFulfilled(null); |
832 | 831 | }); |
@@ -871,7 +870,7 @@ discard block |
||
871 | 870 | ); |
872 | 871 | $promise = $this->getPromise($completed); |
873 | 872 | if ($promise) { |
874 | - return $promise->then(null, function ($error) use ($fieldNodes, $path) { |
|
873 | + return $promise->then(null, function($error) use ($fieldNodes, $path) { |
|
875 | 874 | return $this->exeContext->promises->createRejected(Error::createLocatedError($error, $fieldNodes, $path)); |
876 | 875 | }); |
877 | 876 | } |
@@ -925,7 +924,7 @@ discard block |
||
925 | 924 | |
926 | 925 | // If result is a Promise, apply-lift over completeValue. |
927 | 926 | if ($promise) { |
928 | - return $promise->then(function (&$resolved) use ($returnType, $fieldNodes, $info, $path) { |
|
927 | + return $promise->then(function(&$resolved) use ($returnType, $fieldNodes, $info, $path) { |
|
929 | 928 | return $this->completeValue($returnType, $fieldNodes, $info, $path, $resolved); |
930 | 929 | }); |
931 | 930 | } |
@@ -970,8 +969,8 @@ discard block |
||
970 | 969 | $hint = "Make sure that type loader returns the same instance as defined in {$info->parentType}.{$info->fieldName}"; |
971 | 970 | } |
972 | 971 | throw new InvariantViolation( |
973 | - "Schema must contain unique named types but contains multiple types named \"$returnType\". ". |
|
974 | - "$hint ". |
|
972 | + "Schema must contain unique named types but contains multiple types named \"$returnType\". " . |
|
973 | + "$hint " . |
|
975 | 974 | "(see http://webonyx.github.io/graphql-php/type-system/#type-registry)." |
976 | 975 | ); |
977 | 976 | } |
@@ -1133,14 +1132,13 @@ discard block |
||
1133 | 1132 | ) |
1134 | 1133 | { |
1135 | 1134 | $runtimeType = is_string($runtimeTypeOrName) ? |
1136 | - $this->exeContext->schema->getType($runtimeTypeOrName) : |
|
1137 | - $runtimeTypeOrName; |
|
1135 | + $this->exeContext->schema->getType($runtimeTypeOrName) : $runtimeTypeOrName; |
|
1138 | 1136 | |
1139 | 1137 | if (!$runtimeType instanceof ObjectType) { |
1140 | 1138 | throw new InvariantViolation( |
1141 | 1139 | "Abstract type {$returnType} must resolve to an Object type at " . |
1142 | 1140 | "runtime for field {$info->parentType}.{$info->fieldName} with " . |
1143 | - 'value "' . Utils::printSafe($result) . '", received "'. Utils::printSafe($runtimeType) . '".' . |
|
1141 | + 'value "' . Utils::printSafe($result) . '", received "' . Utils::printSafe($runtimeType) . '".' . |
|
1144 | 1142 | 'Either the ' . $returnType . ' type should provide a "resolveType" ' . |
1145 | 1143 | 'function or each possible types should provide an "isTypeOf" function.' |
1146 | 1144 | ); |
@@ -1154,8 +1152,8 @@ discard block |
||
1154 | 1152 | |
1155 | 1153 | if ($runtimeType !== $this->exeContext->schema->getType($runtimeType->name)) { |
1156 | 1154 | throw new InvariantViolation( |
1157 | - "Schema must contain unique named types but contains multiple types named \"$runtimeType\". ". |
|
1158 | - "Make sure that `resolveType` function of abstract type \"{$returnType}\" returns the same ". |
|
1155 | + "Schema must contain unique named types but contains multiple types named \"$runtimeType\". " . |
|
1156 | + "Make sure that `resolveType` function of abstract type \"{$returnType}\" returns the same " . |
|
1159 | 1157 | "type instance as referenced anywhere else within the schema " . |
1160 | 1158 | "(see http://webonyx.github.io/graphql-php/type-system/#type-registry)." |
1161 | 1159 | ); |
@@ -1213,13 +1211,13 @@ discard block |
||
1213 | 1211 | return $returnType->serialize($result); |
1214 | 1212 | } catch (\Exception $error) { |
1215 | 1213 | throw new InvariantViolation( |
1216 | - 'Expected a value of type "'. Utils::printSafe($returnType) . '" but received: ' . Utils::printSafe($result), |
|
1214 | + 'Expected a value of type "' . Utils::printSafe($returnType) . '" but received: ' . Utils::printSafe($result), |
|
1217 | 1215 | 0, |
1218 | 1216 | $error |
1219 | 1217 | ); |
1220 | 1218 | } catch (\Throwable $error) { |
1221 | 1219 | throw new InvariantViolation( |
1222 | - 'Expected a value of type "'. Utils::printSafe($returnType) . '" but received: ' . Utils::printSafe($result), |
|
1220 | + 'Expected a value of type "' . Utils::printSafe($returnType) . '" but received: ' . Utils::printSafe($result), |
|
1223 | 1221 | 0, |
1224 | 1222 | $error |
1225 | 1223 | ); |
@@ -1359,9 +1357,9 @@ discard block |
||
1359 | 1357 | |
1360 | 1358 | if ($abstractType instanceof InterfaceType && $info->schema->getConfig()->typeLoader) { |
1361 | 1359 | Warning::warnOnce( |
1362 | - "GraphQL Interface Type `{$abstractType->name}` returned `null` from it`s `resolveType` function ". |
|
1360 | + "GraphQL Interface Type `{$abstractType->name}` returned `null` from it`s `resolveType` function " . |
|
1363 | 1361 | 'for value: ' . Utils::printSafe($value) . '. Switching to slow resolution method using `isTypeOf` ' . |
1364 | - 'of all possible implementations. It requires full schema scan and degrades query performance significantly. '. |
|
1362 | + 'of all possible implementations. It requires full schema scan and degrades query performance significantly. ' . |
|
1365 | 1363 | ' Make sure your `resolveType` always returns valid implementation or throws.', |
1366 | 1364 | Warning::WARNING_FULL_SCHEMA_SCAN |
1367 | 1365 | ); |
@@ -126,7 +126,7 @@ |
||
126 | 126 | Utils::invariant($this->state !== self::PENDING, 'Cannot enqueue derived promises when parent is still pending'); |
127 | 127 | |
128 | 128 | foreach ($this->waiting as $descriptor) { |
129 | - self::getQueue()->enqueue(function () use ($descriptor) { |
|
129 | + self::getQueue()->enqueue(function() use ($descriptor) { |
|
130 | 130 | /** @var $promise self */ |
131 | 131 | list($promise, $onFulfilled, $onRejected) = $descriptor; |
132 | 132 |
@@ -68,7 +68,7 @@ |
||
68 | 68 | public function all(array $promisesOrValues) |
69 | 69 | { |
70 | 70 | // TODO: rework with generators when PHP minimum required version is changed to 5.5+ |
71 | - $promisesOrValues = Utils::map($promisesOrValues, function ($item) { |
|
71 | + $promisesOrValues = Utils::map($promisesOrValues, function($item) { |
|
72 | 72 | return $item instanceof Promise ? $item->adoptedPromise : $item; |
73 | 73 | }); |
74 | 74 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if ($coercionErrors) { |
71 | 71 | $messagePrelude = "Variable \"\$$varName\" got invalid value " . Utils::printSafeJson($value) . '; '; |
72 | 72 | |
73 | - foreach($coercionErrors as $error) { |
|
73 | + foreach ($coercionErrors as $error) { |
|
74 | 74 | $errors[] = new Error( |
75 | 75 | $messagePrelude . $error->getMessage(), |
76 | 76 | $error->getNodes(), |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $coercedValues = []; |
113 | 113 | |
114 | 114 | /** @var ArgumentNode[] $argNodeMap */ |
115 | - $argNodeMap = $argNodes ? Utils::keyMap($argNodes, function (ArgumentNode $arg) { |
|
115 | + $argNodeMap = $argNodes ? Utils::keyMap($argNodes, function(ArgumentNode $arg) { |
|
116 | 116 | return $arg->name->value; |
117 | 117 | }) : []; |
118 | 118 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | 'Argument "' . $name . '" of required type "' . Utils::printSafe($argType) . '" was ' . |
147 | 147 | 'provided the variable "$' . $variableName . '" which was not provided ' . |
148 | 148 | 'a runtime value.', |
149 | - [ $argumentNode->value ] |
|
149 | + [$argumentNode->value] |
|
150 | 150 | ); |
151 | 151 | } |
152 | 152 | } else { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | // continue with an invalid argument value. |
159 | 159 | throw new Error( |
160 | 160 | 'Argument "' . $name . '" has invalid value ' . Printer::doPrint($valueNode) . '.', |
161 | - [ $argumentNode->value ] |
|
161 | + [$argumentNode->value] |
|
162 | 162 | ); |
163 | 163 | } |
164 | 164 | $coercedValues[$name] = $coercedValue; |
@@ -1251,7 +1251,7 @@ |
||
1251 | 1251 | Token::BRACE_L, |
1252 | 1252 | [$this, 'parseEnumValueDefinition'], |
1253 | 1253 | Token::BRACE_R |
1254 | - ) |
|
1254 | + ) |
|
1255 | 1255 | : new NodeList([]); |
1256 | 1256 | } |
1257 | 1257 |
@@ -465,8 +465,7 @@ discard block |
||
465 | 465 | Token::PAREN_L, |
466 | 466 | [$this, 'parseVariableDefinition'], |
467 | 467 | Token::PAREN_R |
468 | - ) : |
|
469 | - new NodeList([]); |
|
468 | + ) : new NodeList([]); |
|
470 | 469 | } |
471 | 470 | |
472 | 471 | /** |
@@ -528,8 +527,7 @@ discard block |
||
528 | 527 | function parseSelection() |
529 | 528 | { |
530 | 529 | return $this->peek(Token::SPREAD) ? |
531 | - $this->parseFragment() : |
|
532 | - $this->parseField(); |
|
530 | + $this->parseFragment() : $this->parseField(); |
|
533 | 531 | } |
534 | 532 | |
535 | 533 | /** |
@@ -568,8 +566,7 @@ discard block |
||
568 | 566 | { |
569 | 567 | $item = $isConst ? 'parseConstArgument' : 'parseArgument'; |
570 | 568 | return $this->peek(Token::PAREN_L) ? |
571 | - $this->many(Token::PAREN_L, [$this, $item], Token::PAREN_R) : |
|
572 | - new NodeList([]); |
|
569 | + $this->many(Token::PAREN_L, [$this, $item], Token::PAREN_R) : new NodeList([]); |
|
573 | 570 | } |
574 | 571 | |
575 | 572 | /** |
@@ -127,11 +127,13 @@ |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | foreach (get_object_vars($node) as $prop => $propValue) { |
130 | - if (isset($result[$prop])) |
|
131 | - continue; |
|
130 | + if (isset($result[$prop])) { |
|
131 | + continue; |
|
132 | + } |
|
132 | 133 | |
133 | - if ($propValue === null) |
|
134 | - continue; |
|
134 | + if ($propValue === null) { |
|
135 | + continue; |
|
136 | + } |
|
135 | 137 | |
136 | 138 | if (is_array($propValue) || $propValue instanceof NodeList) { |
137 | 139 | $tmp = []; |
@@ -211,7 +211,7 @@ |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | $errMessage = $code === 39 |
214 | - ? "Unexpected single quote character ('), did you mean to use ". 'a double quote (")?' |
|
214 | + ? "Unexpected single quote character ('), did you mean to use " . 'a double quote (")?' |
|
215 | 215 | : 'Cannot parse the unexpected character ' . Utils::printCharCode($code) . '.'; |
216 | 216 | |
217 | 217 | throw new SyntaxError( |
@@ -111,7 +111,7 @@ |
||
111 | 111 | */ |
112 | 112 | public function getDescription() |
113 | 113 | { |
114 | - return $this->kind . ($this->value ? ' "' . $this->value . '"' : ''); |
|
114 | + return $this->kind . ($this->value ? ' "' . $this->value . '"' : ''); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | }, |
150 | 150 | NodeKind::STRING => function(StringValueNode $node, $key) { |
151 | 151 | if ($node->block) { |
152 | - return $this->printBlockString($node->value, $key === 'description'); |
|
152 | + return $this->printBlockString($node->value, $key === 'description'); |
|
153 | 153 | } |
154 | 154 | return json_encode($node->value); |
155 | 155 | }, |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | return $this->join([ |
223 | 223 | $def->description, |
224 | 224 | $def->name |
225 | - . $this->wrap('(', $this->join($def->arguments, ', '), ')') |
|
226 | - . ': ' . $def->type |
|
227 | - . $this->wrap(' ', $this->join($def->directives, ' ')) |
|
225 | + . $this->wrap('(', $this->join($def->arguments, ', '), ')') |
|
226 | + . ': ' . $def->type |
|
227 | + . $this->wrap(' ', $this->join($def->directives, ' ')) |
|
228 | 228 | ], "\n"); |
229 | 229 | }, |
230 | 230 | NodeKind::INPUT_VALUE_DEFINITION => function(InputValueDefinitionNode $def) { |
@@ -392,7 +392,7 @@ |
||
392 | 392 | $separator, |
393 | 393 | Utils::filter( |
394 | 394 | $maybeArray, |
395 | - function($x) { return !!$x;} |
|
395 | + function($x) { return !!$x; } |
|
396 | 396 | ) |
397 | 397 | ) |
398 | 398 | : ''; |