public function setType(?string $type): self
    {
        if (!$this->isValidType($type)) {
            throw new \InvalidArgumentException(\sprintf(
                "Invalid type '%s'. Must be either NULL, one of %s, or a fully qualified class name or interface",
                $type,
                \implode(', ', $this->getValidTypes())
            ));
        }

        $this->type = $type;

        return $this;
    }
public function setType(?string $type): self
    {
        if (!$this->isValidType($type)) {
            throw new \InvalidArgumentException(\sprintf(
                "Invalid type '%s'. Must be either NULL, one of %s, or a fully qualified class name or interface",
                $type,
                \implode(', ', $this->getValidTypes())
            ));
        }

        $this->type = $type;

        return $this;
    }
public function setType ( ? string $ type ) : self { if ( ! $ this -> isValidType ( $ type ) ) { throw new \ InvalidArgumentException ( \ sprintf ( "Invalid type '%s'. Must be either NULL, one of %s, or a fully qualified class name or interface" , $ type , \ implode ( ', ' , $ this -> getValidTypes ( ) ) ) ) ; } $ this -> type = $ type ; return $ this ; }
Sets the type all elements in the collection must be. Can be a primitive type, class name or interface.

@see $typeMap for valid primitive types.

@param string|null $type

@return TypeValidator
Sets the type all elements in the collection must be . Can be a primitive type class name or interface .