Skip to content

Commit

Permalink
Simplify type hints in wrapping types (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Jan 19, 2021
1 parent 5289a54 commit dd46e8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 0 additions & 3 deletions src/Type/Definition/ListOfType.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ public function getOfType()
return Schema::resolveType($this->ofType);
}

/**
* @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|(Type&WrappingType)
*/
public function getWrappedType(bool $recurse = false) : Type
{
$type = $this->getOfType();
Expand Down
13 changes: 6 additions & 7 deletions src/Type/Definition/NonNull.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,21 @@

namespace GraphQL\Type\Definition;

use GraphQL\Error\InvariantViolation;
use GraphQL\Type\Schema;
use function is_callable;

class NonNull extends Type implements WrappingType, OutputType, InputType
{
/** @var callable|(NullableType&Type) */
/** @var callable():(NullableType&Type)|(NullableType&Type) */
private $ofType;

/**
* code sniffer doesn't understand this syntax. Pr with a fix here: waiting on https://github.com/squizlabs/PHP_CodeSniffer/pull/2919
* phpcs:disable Squiz.Commenting.FunctionComment.SpacingAfterParamType
* @param (NullableType&Type)|callable $type
* @param callable():(NullableType&Type)|(NullableType&Type) $type
*/
public function __construct($type)
{
/** @var Type&NullableType $nullableType*/
$nullableType = $type;
$this->ofType = $nullableType;
$this->ofType = $type;
}

public function toString() : string
Expand All @@ -35,6 +31,9 @@ public function getOfType()
return Schema::resolveType($this->ofType);
}

/**
* @return (NullableType&Type)
*/
public function getWrappedType(bool $recurse = false) : Type
{
$type = $this->getOfType();
Expand Down

0 comments on commit dd46e8f

Please sign in to comment.