src/Common/Collection/TypeCollection.php
public function set($key, $value)
    {
        if (!$this->acceptsType($value)) {
            throw $this->doUnexpectedValueError($value);
        }

        parent::set($key, $value);
    }
public function set($key, $value)
    {
        if (!$this->acceptsType($value)) {
            throw $this->doUnexpectedValueError($value);
        }

        parent::set($key, $value);
    }
{@inheritdoc}

@throws UnexpectedValueException