Automattic\WooCommerce\Vendor\GraphQL\Type\Definition

ListOfType{}WC 1.0└─ WrappingType, OutputType, NullableType, InputType, Type

No Hooks.

Usage

$ListOfType = new ListOfType();
// use class methods

Methods

  1. public __construct($type)
  2. public getInnermostType()
  3. public getWrappedType()
  4. public toString()

ListOfType{} code WC 10.9.1

class ListOfType extends Type implements WrappingType, OutputType, NullableType, InputType
{
    /**
     * @var Type|callable
     *
     * @phpstan-var OfType|callable(): OfType
     */
    private $wrappedType;

    /**
     * @param Type|callable $type
     *
     * @phpstan-param OfType|callable(): OfType $type
     */
    public function __construct($type)
    {
        $this->wrappedType = $type;
    }

    public function toString(): string
    {
        return '[' . $this->getWrappedType()->toString() . ']';
    }

    /** @phpstan-return OfType */
    public function getWrappedType(): Type
    {
        return Schema::resolveType($this->wrappedType);
    }

    public function getInnermostType(): NamedType
    {
        $type = $this->getWrappedType();
        while ($type instanceof WrappingType) {
            $type = $type->getWrappedType();
        }

        assert($type instanceof NamedType, 'known because we unwrapped all the way down');

        return $type;
    }
}