diff --git a/src/Type/Definition/EnumType.php b/src/Type/Definition/EnumType.php index 2b42590..b565a25 100644 --- a/src/Type/Definition/EnumType.php +++ b/src/Type/Definition/EnumType.php @@ -22,7 +22,7 @@ use function sprintf; /** * Class EnumType */ -class EnumType extends Type implements InputType, OutputType, LeafType, NamedType +class EnumType extends Type implements InputType, OutputType, LeafType, NullableType, NamedType { /** @var EnumTypeDefinitionNode|null */ public $astNode; diff --git a/src/Type/Definition/InputObjectType.php b/src/Type/Definition/InputObjectType.php index e43caad..756e142 100644 --- a/src/Type/Definition/InputObjectType.php +++ b/src/Type/Definition/InputObjectType.php @@ -18,7 +18,7 @@ use function sprintf; /** * Class InputObjectType */ -class InputObjectType extends Type implements InputType, NamedType +class InputObjectType extends Type implements InputType, NullableType, NamedType { /** @var InputObjectTypeDefinitionNode|null */ public $astNode; diff --git a/src/Type/Definition/InterfaceType.php b/src/Type/Definition/InterfaceType.php index ff01a48..52ad81d 100644 --- a/src/Type/Definition/InterfaceType.php +++ b/src/Type/Definition/InterfaceType.php @@ -15,7 +15,7 @@ use function sprintf; /** * Class InterfaceType */ -class InterfaceType extends Type implements AbstractType, OutputType, CompositeType, NamedType +class InterfaceType extends Type implements AbstractType, OutputType, CompositeType, NullableType, NamedType { /** @var InterfaceTypeDefinitionNode|null */ public $astNode; diff --git a/src/Type/Definition/ListOfType.php b/src/Type/Definition/ListOfType.php index 7fdb6e6..29e3438 100644 --- a/src/Type/Definition/ListOfType.php +++ b/src/Type/Definition/ListOfType.php @@ -7,7 +7,7 @@ namespace GraphQL\Type\Definition; /** * Class ListOfType */ -class ListOfType extends Type implements WrappingType, OutputType, InputType +class ListOfType extends Type implements WrappingType, OutputType, NullableType, InputType { /** @var ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType */ public $ofType; diff --git a/src/Type/Definition/NonNull.php b/src/Type/Definition/NonNull.php index f3ebbca..cc80be0 100644 --- a/src/Type/Definition/NonNull.php +++ b/src/Type/Definition/NonNull.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace GraphQL\Type\Definition; -use Exception; -use GraphQL\Error\InvariantViolation; use GraphQL\Utils\Utils; /** @@ -13,13 +11,11 @@ use GraphQL\Utils\Utils; */ class NonNull extends Type implements WrappingType, OutputType, InputType { - /** @var ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType */ + /** @var NullableType */ private $ofType; /** - * @param callable|Type $type - * - * @throws Exception + * @param NullableType $type */ public function __construct($type) { @@ -29,7 +25,7 @@ class NonNull extends Type implements WrappingType, OutputType, InputType /** * @param mixed $type * - * @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType + * @return NullableType */ public static function assertNullableType($type) { @@ -67,9 +63,7 @@ class NonNull extends Type implements WrappingType, OutputType, InputType /** * @param bool $recurse * - * @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType - * - * @throws InvariantViolation + * @return Type */ public function getWrappedType($recurse = false) { diff --git a/src/Type/Definition/NullableType.php b/src/Type/Definition/NullableType.php new file mode 100644 index 0000000..7ff70b2 --- /dev/null +++ b/src/Type/Definition/NullableType.php @@ -0,0 +1,20 @@ +; + */ + +interface NullableType +{ +} diff --git a/src/Type/Definition/ObjectType.php b/src/Type/Definition/ObjectType.php index ac40258..f509293 100644 --- a/src/Type/Definition/ObjectType.php +++ b/src/Type/Definition/ObjectType.php @@ -54,7 +54,7 @@ use function sprintf; * } * ]); */ -class ObjectType extends Type implements OutputType, CompositeType, NamedType +class ObjectType extends Type implements OutputType, CompositeType, NullableType, NamedType { /** @var ObjectTypeDefinitionNode|null */ public $astNode; diff --git a/src/Type/Definition/ScalarType.php b/src/Type/Definition/ScalarType.php index db4e63f..17bf6e7 100644 --- a/src/Type/Definition/ScalarType.php +++ b/src/Type/Definition/ScalarType.php @@ -27,7 +27,7 @@ use function is_string; * } * } */ -abstract class ScalarType extends Type implements OutputType, InputType, LeafType, NamedType +abstract class ScalarType extends Type implements OutputType, InputType, LeafType, NullableType, NamedType { /** @var ScalarTypeDefinitionNode|null */ public $astNode; diff --git a/src/Type/Definition/Type.php b/src/Type/Definition/Type.php index c349d11..5b8e414 100644 --- a/src/Type/Definition/Type.php +++ b/src/Type/Definition/Type.php @@ -137,7 +137,7 @@ abstract class Type implements JsonSerializable } /** - * @param ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType $wrappedType + * @param NullableType $wrappedType * * @return NonNull * @@ -338,7 +338,7 @@ abstract class Type implements JsonSerializable /** * @param Type $type * - * @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType + * @return NullableType * * @api */ diff --git a/src/Type/Definition/UnionType.php b/src/Type/Definition/UnionType.php index a8e6fd7..8a735e3 100644 --- a/src/Type/Definition/UnionType.php +++ b/src/Type/Definition/UnionType.php @@ -17,7 +17,7 @@ use function sprintf; /** * Class UnionType */ -class UnionType extends Type implements AbstractType, OutputType, CompositeType, NamedType +class UnionType extends Type implements AbstractType, OutputType, CompositeType, NullableType, NamedType { /** @var UnionTypeDefinitionNode */ public $astNode;