Skip to content

Commit

Permalink
Enhance type definitions for Executor
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Aug 24, 2020
1 parent 4f34309 commit 9d73e40
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 136 deletions.
37 changes: 19 additions & 18 deletions src/Executor/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class Executor
{
/** @var callable|string[] */
/** @var callable */
private static $defaultFieldResolver = [self::class, 'defaultFieldResolver'];

/** @var PromiseAdapter */
Expand All @@ -35,7 +35,7 @@ public static function getDefaultFieldResolver() : callable
}

/**
* Custom default resolve function.
* Set a custom default resolve function.
*/
public static function setDefaultFieldResolver(callable $fieldResolver)
{
Expand All @@ -47,6 +47,9 @@ public static function getPromiseAdapter() : PromiseAdapter
return self::$defaultPromiseAdapter ?? (self::$defaultPromiseAdapter = new SyncPromiseAdapter());
}

/**
* Set a custom default promise adapter.
*/
public static function setPromiseAdapter(?PromiseAdapter $defaultPromiseAdapter = null)
{
self::$defaultPromiseAdapter = $defaultPromiseAdapter;
Expand All @@ -58,9 +61,7 @@ public static function getImplementationFactory() : callable
}

/**
* Custom executor implementation factory.
*
* Will be called with as
* Set a custom executor implementation factory.
*/
public static function setImplementationFactory(callable $implementationFactory)
{
Expand All @@ -70,13 +71,13 @@ public static function setImplementationFactory(callable $implementationFactory)
/**
* Executes DocumentNode against given $schema.
*
* Always returns ExecutionResult and never throws. All errors which occur during operation
* execution are collected in `$result->errors`.
* Always returns ExecutionResult and never throws.
* All errors which occur during operation execution are collected in `$result->errors`.
*
* @param mixed|null $rootValue
* @param mixed|null $contextValue
* @param mixed[]|ArrayAccess|null $variableValues
* @param string|null $operationName
* @param mixed|null $rootValue
* @param mixed|null $contextValue
* @param array<mixed>|ArrayAccess|null $variableValues
* @param string|null $operationName
*
* @return ExecutionResult|Promise
*
Expand Down Expand Up @@ -119,10 +120,10 @@ public static function execute(
*
* Useful for async PHP platforms.
*
* @param mixed|null $rootValue
* @param mixed|null $contextValue
* @param mixed[]|null $variableValues
* @param string|null $operationName
* @param mixed|null $rootValue
* @param mixed|null $contextValue
* @param array<mixed>|null $variableValues
* @param string|null $operationName
*
* @return Promise
*
Expand Down Expand Up @@ -161,9 +162,9 @@ public static function promiseToExecute(
* and returns it as the result, or if it's a function, returns the result
* of calling that function while passing along args and context.
*
* @param mixed $objectValue
* @param mixed[] $args
* @param mixed|null $contextValue
* @param mixed $objectValue
* @param array<string, mixed> $args
* @param mixed|null $contextValue
*
* @return mixed|null
*/
Expand Down

0 comments on commit 9d73e40

Please sign in to comment.