Completed
Pull Request — master (#201)
by Christoffer
02:54
created

InterfaceType::afterConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Digia\GraphQL\Type\Definition;
4
5
use Digia\GraphQL\Error\InvariantException;
6
use Digia\GraphQL\Language\Node\ASTNodeAwareInterface;
7
use Digia\GraphQL\Language\Node\ASTNodeTrait;
8
use Digia\GraphQL\Language\Node\InterfaceTypeDefinitionNode;
9
use Digia\GraphQL\Language\Node\InterfaceTypeExtensionNode;
10
use function Digia\GraphQL\Util\invariant;
11
12
/**
13
 * Interface Type Definition
14
 *
15
 * When a field can return one of a heterogeneous set of types, a Interface type
16
 * is used to describe what types are possible, what fields are in common across
17
 * all types, as well as a function to determine which type is actually used
18
 * when the field is resolved.
19
 *
20
 * Example:
21
 *     $EntityType = GraphQLInterfaceType([
22
 *       'name' => 'Entity',
23
 *       'fields' => [
24
 *         'name' => ['type' => GraphQLString()]
25
 *       ]
26
 *     ]);
27
 */
28
class InterfaceType implements NamedTypeInterface, AbstractTypeInterface, CompositeTypeInterface,
29
    OutputTypeInterface, ASTNodeAwareInterface
30
{
31
    use NameTrait;
32
    use DescriptionTrait;
33
    use FieldsTrait;
34
    use ResolveTypeTrait;
35
    use ASTNodeTrait;
36
    use ExtensionASTNodesTrait;
37
38
    /**
39
     * InterfaceType constructor.
40
     *
41
     * @param string                           $name
42
     * @param null|string                      $description
43
     * @param array|callable                   $fieldsOrThunk
44
     * @param callable|null                    $resolveTypeCallback
45
     * @param InterfaceTypeDefinitionNode|null $astNode
46
     * @param InterfaceTypeExtensionNode[]     $extensionASTNodes
47
     * @throws InvariantException
48
     */
49
    public function __construct(
50
        string $name,
51
        ?string $description,
52
        $fieldsOrThunk,
53
        ?callable $resolveTypeCallback,
54
        ?InterfaceTypeDefinitionNode $astNode,
55
        array $extensionASTNodes
56
    ) {
57
        $this->name                = $name;
58
        $this->description         = $description;
59
        $this->fieldsOrThunk       = $fieldsOrThunk;
60
        $this->resolveTypeCallback = $resolveTypeCallback;
61
        $this->astNode             = $astNode;
62
        $this->extensionAstNodes   = $extensionASTNodes;
0 ignored issues
show
Documentation Bug introduced by
It seems like $extensionASTNodes of type Digia\GraphQL\Language\N...faceTypeExtensionNode[] is incompatible with the declared type Digia\GraphQL\Language\N...jectTypeExtensionNode[] of property $extensionAstNodes.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
63
64
        invariant(null !== $this->getName(), 'Must provide name.');
65
    }
66
}
67