Rename parameters and private fields to match what they contain

This commit is contained in:
spawnia 2019-06-23 18:40:56 +02:00
parent 93ccd7351d
commit bc66034f40
3 changed files with 30 additions and 28 deletions

View File

@ -9,7 +9,7 @@
"API"
],
"require": {
"php": "^7.1||^8.0",
"php": "^7.1",
"ext-json": "*",
"ext-mbstring": "*"
},

View File

@ -45,7 +45,7 @@ class ExecutionContext
public $errors;
/** @var PromiseAdapter */
public $promises;
public $promiseAdapter;
public function __construct(
$schema,
@ -53,7 +53,7 @@ class ExecutionContext
$root,
$contextValue,
$operation,
$variables,
$variableValues,
$errors,
$fieldResolver,
$promiseAdapter
@ -63,10 +63,10 @@ class ExecutionContext
$this->rootValue = $root;
$this->contextValue = $contextValue;
$this->operation = $operation;
$this->variableValues = $variables;
$this->variableValues = $variableValues;
$this->errors = $errors ?: [];
$this->fieldResolver = $fieldResolver;
$this->promises = $promiseAdapter;
$this->promiseAdapter = $promiseAdapter;
}
public function addError(Error $error)

View File

@ -212,7 +212,7 @@ class ReferenceExecutor implements ExecutorImplementation
// But for the "sync" case it is always fulfilled
return $this->isPromise($result)
? $result
: $this->exeContext->promises->createFulfilled($result);
: $this->exeContext->promiseAdapter->createFulfilled($result);
}
/**
@ -262,7 +262,7 @@ class ReferenceExecutor implements ExecutorImplementation
if ($error instanceof Error) {
$this->exeContext->addError($error);
return $this->exeContext->promises->createFulfilled(null);
return $this->exeContext->promiseAdapter->createFulfilled(null);
}
}
);
@ -574,6 +574,7 @@ class ReferenceExecutor implements ExecutorImplementation
/**
* This method looks up the field on the given type definition.
*
* It has special casing for the two introspection fields, __schema
* and __typename. __typename is special because it can always be
* queried as a field, even in situations where no other fields
@ -608,8 +609,8 @@ class ReferenceExecutor implements ExecutorImplementation
}
/**
* Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
* function. Returns the result of resolveFn or the abrupt-return Error object.
* Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField` function.
* Returns the result of resolveFn or the abrupt-return Error object.
*
* @param FieldDefinition $fieldDef
* @param FieldNode $fieldNode
@ -623,7 +624,7 @@ class ReferenceExecutor implements ExecutorImplementation
private function resolveOrError($fieldDef, $fieldNode, $resolveFn, $source, $context, $info)
{
try {
// Build hash of arguments from the field.arguments AST, using the
// Build a map of arguments from the field.arguments AST, using the
// variables scope to fulfill any variable references.
$args = Values::getArgumentValues(
$fieldDef,
@ -685,7 +686,7 @@ class ReferenceExecutor implements ExecutorImplementation
function ($error) use ($exeContext) {
$exeContext->addError($error);
return $this->exeContext->promises->createFulfilled(null);
return $this->exeContext->promiseAdapter->createFulfilled(null);
}
);
}
@ -732,7 +733,7 @@ class ReferenceExecutor implements ExecutorImplementation
return $promise->then(
null,
function ($error) use ($fieldNodes, $path) {
return $this->exeContext->promises->createRejected(Error::createLocatedError(
return $this->exeContext->promiseAdapter->createRejected(Error::createLocatedError(
$error,
$fieldNodes,
$path
@ -864,7 +865,7 @@ class ReferenceExecutor implements ExecutorImplementation
*/
private function isPromise($value)
{
return $value instanceof Promise || $this->exeContext->promises->isThenable($value);
return $value instanceof Promise || $this->exeContext->promiseAdapter->isThenable($value);
}
/**
@ -880,12 +881,12 @@ class ReferenceExecutor implements ExecutorImplementation
if ($value === null || $value instanceof Promise) {
return $value;
}
if ($this->exeContext->promises->isThenable($value)) {
$promise = $this->exeContext->promises->convertThenable($value);
if ($this->exeContext->promiseAdapter->isThenable($value)) {
$promise = $this->exeContext->promiseAdapter->convertThenable($value);
if (! $promise instanceof Promise) {
throw new InvariantViolation(sprintf(
'%s::convertThenable is expected to return instance of GraphQL\Executor\Promise\Promise, got: %s',
get_class($this->exeContext->promises),
get_class($this->exeContext->promiseAdapter),
Utils::printSafe($promise)
));
}
@ -927,28 +928,27 @@ class ReferenceExecutor implements ExecutorImplementation
}
/**
* Complete a list value by completing each item in the list with the
* inner type
* Complete a list value by completing each item in the list with the inner type.
*
* @param FieldNode[] $fieldNodes
* @param mixed[] $path
* @param mixed $result
* @param mixed[]|Traversable &$results
*
* @return mixed[]|Promise
*
* @throws Exception
*/
private function completeListValue(ListOfType $returnType, $fieldNodes, ResolveInfo $info, $path, &$result)
private function completeListValue(ListOfType $returnType, $fieldNodes, ResolveInfo $info, $path, &$results)
{
$itemType = $returnType->getWrappedType();
Utils::invariant(
is_array($result) || $result instanceof Traversable,
is_array($results) || $results instanceof Traversable,
'User Error: expected iterable, but did not find one for field ' . $info->parentType . '.' . $info->fieldName . '.'
);
$containsPromise = false;
$i = 0;
$completedItems = [];
foreach ($result as $item) {
foreach ($results as $item) {
$fieldPath = $path;
$fieldPath[] = $i++;
$info->path = $fieldPath;
@ -959,7 +959,9 @@ class ReferenceExecutor implements ExecutorImplementation
$completedItems[] = $completedItem;
}
return $containsPromise ? $this->exeContext->promises->all($completedItems) : $completedItems;
return $containsPromise
? $this->exeContext->promiseAdapter->all($completedItems)
: $completedItems;
}
/**
@ -1101,7 +1103,7 @@ class ReferenceExecutor implements ExecutorImplementation
}
}
if (! empty($promisedIsTypeOfResults)) {
return $this->exeContext->promises->all($promisedIsTypeOfResults)
return $this->exeContext->promiseAdapter->all($promisedIsTypeOfResults)
->then(static function ($isTypeOfResults) use ($possibleTypes) {
foreach ($isTypeOfResults as $index => $result) {
if ($result) {
@ -1187,7 +1189,7 @@ class ReferenceExecutor implements ExecutorImplementation
/**
* @param FieldNode[] $fieldNodes
* @param mixed[] $path
* @param mixed[] $result
* @param mixed $result
*
* @return mixed[]|Promise|stdClass
*
@ -1299,7 +1301,7 @@ class ReferenceExecutor implements ExecutorImplementation
{
$keys = array_keys($assoc);
$valuesAndPromises = array_values($assoc);
$promise = $this->exeContext->promises->all($valuesAndPromises);
$promise = $this->exeContext->promiseAdapter->all($valuesAndPromises);
return $promise->then(static function ($values) use ($keys) {
$resolvedResults = [];