public function define($id, $type)
    {
        $id = (string) $id;

        $this->validateName($id);

        if ($type[0] == ':') {
            $expectedType = substr($type, 1);
            $allowedTypes = (array) $this->getAllowedTypes();
            if (!in_array($expectedType, $allowedTypes)) {
                throw new InvalidArgumentException(sprintf('Cannot use type %s to define item "%s" in %s container. Allowed types are: %s.',
                    $expectedType, $id, $this->name, join(', ', $allowedTypes)));
            }
        } else {
            if (!class_exists($type)) {
                throw new InvalidArgumentException(sprintf('Cannot use non-existing class %s as type to define item "%s" in %s container.',
                    $type, $id, $this->name));
            }
        }

        $this->typemap[$id] = $type;
    }