protected function buildInstanceType(Definition $type, $serviceId, $tagName)
    {
        $parents = class_parents($type->getClass());
        $args = $type->getArguments();
        $ref = new \ReflectionClass($type);

        if (\in_array(AbstractSimpleType::class, $parents, true)
                && (0 === \count($args) || (1 === \count($args) && \is_string($args[0])))) {
            return $ref->newInstanceArgs($args);
        }

        throw new InvalidConfigurationException(sprintf('The service id "%s" must have the "class" parameter in the "%s" tag.', $serviceId, $tagName));
    }