@@ -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; |
@@ -260,11 +260,11 @@ |
||
| 260 | 260 | $nodes = $this->nodes; |
| 261 | 261 | |
| 262 | 262 | if ($positions && $source) { |
| 263 | - $this->locations = array_map(function ($pos) use ($source) { |
|
| 263 | + $this->locations = array_map(function($pos) use ($source) { |
|
| 264 | 264 | return $source->getLocation($pos); |
| 265 | 265 | }, $positions); |
| 266 | 266 | } else if ($nodes) { |
| 267 | - $this->locations = array_filter(array_map(function ($node) { |
|
| 267 | + $this->locations = array_filter(array_map(function($node) { |
|
| 268 | 268 | if ($node->loc) { |
| 269 | 269 | return $node->loc->source->getLocation($node->loc->start); |
| 270 | 270 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $printedLocations = []; |
| 42 | 42 | if ($error->nodes) { |
| 43 | 43 | /** @var Node $node */ |
| 44 | - foreach($error->nodes as $node) { |
|
| 44 | + foreach ($error->nodes as $node) { |
|
| 45 | 45 | if ($node->loc) { |
| 46 | 46 | $printedLocations[] = self::highlightSourceAtLocation( |
| 47 | 47 | $node->loc->source, |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | } else if ($error->getSource() && $error->getLocations()) { |
| 53 | 53 | $source = $error->getSource(); |
| 54 | - foreach($error->getLocations() as $location) { |
|
| 54 | + foreach ($error->getLocations() as $location) { |
|
| 55 | 55 | $printedLocations[] = self::highlightSourceAtLocation($source, $location); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $line >= 2 ? (self::lpad($padLen, $prevLineNum) . ': ' . $lines[$line - 2]) : null, |
| 90 | 90 | self::lpad($padLen, $lineNum) . ': ' . $lines[$line - 1], |
| 91 | 91 | self::whitespace(2 + $padLen + $contextColumn - 1) . '^', |
| 92 | - $line < count($lines)? self::lpad($padLen, $nextLineNum) . ': ' . $lines[$line] : null |
|
| 92 | + $line < count($lines) ? self::lpad($padLen, $nextLineNum) . ': ' . $lines[$line] : null |
|
| 93 | 93 | ]; |
| 94 | 94 | |
| 95 | 95 | return join("\n", array_filter($outputLines)); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | // Remove invariant entries as they don't provide much value: |
| 276 | 276 | if ( |
| 277 | 277 | isset($trace[0]['function']) && isset($trace[0]['class']) && |
| 278 | - ('GraphQL\Utils\Utils::invariant' === $trace[0]['class'].'::'.$trace[0]['function'])) { |
|
| 278 | + ('GraphQL\Utils\Utils::invariant' === $trace[0]['class'] . '::' . $trace[0]['function'])) { |
|
| 279 | 279 | array_shift($trace); |
| 280 | 280 | } |
| 281 | 281 | |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | ]; |
| 355 | 355 | |
| 356 | 356 | if (!empty($locations)) { |
| 357 | - $formatted['locations'] = array_map(function($loc) { return $loc->toArray();}, $locations); |
|
| 357 | + $formatted['locations'] = array_map(function($loc) { return $loc->toArray(); }, $locations); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | return $formatted; |
@@ -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 | /** |
@@ -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 | /** |