Repository: symfony/symfony
File: src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php (PHP)

Code before:
        return $this->getPublicContainer()->getParameterBag();
    }

    public function getParameter(string $name): array|bool|string|int|float|\UnitEnum|null
    {
        return $this->getPublicContainer()->getParameter($name);
    }

    public function hasParameter(string $name): bool
    {
        return $this->getPublicContainer()->hasParameter($name);
    }

    public function setParameter(string $name, mixed $value): void
    {
        $this->getPublicContainer()->setParameter($name, $value);
    }

    public function set(string $id, mixed $service): void
    {
        $container = $this->getPublicContainer();
        $renamedId = $this->renamedIds[$id] ?? $id;

        if (isset($this->nonSharedServices[$renamedId])) {
            if (!\is_callable($service)) {
                throw new InvalidArgumentException(\sprintf('The "%s" service is non-shared and must be replaced by a callable.', $id));
            }
            $container->factories[$renamedId] = $container->factories['service_container'][$renamedId] = $service;

            return;
        }

        try {
            $container->set($renamedId, $service);
        } catch (InvalidArgumentException $e) {
            if (!str_starts_with($e->getMessage(), "The \"$renamedId\" service is private")) {
                throw $e;
            }
            if (isset($container->privates[$renamedId])) {
                throw new InvalidArgumentException(\sprintf('The "%s" service is already initialized, you cannot replace it.', $id));
            }
            $container->privates[$renamedId] = $service;
        }
    }

    public function has(string $id): bool
    {
        return $this->getPublicContainer()->has($id) || $this->getPrivateContainer()->has($id);
    }

    public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE): ?object

Review comment (suggestion):
```suggestion
                throw new InvalidArgumentException(\sprintf('The "%s" service is non-shared and must be replaced by a callable that should act as a factory.', $id));
```

Code after:
        return $this->getPublicContainer()->getParameterBag();
    }

    public function getParameter(string $name): array|bool|string|int|float|\UnitEnum|null
    {
        return $this->getPublicContainer()->getParameter($name);
    }

    public function hasParameter(string $name): bool
    {
        return $this->getPublicContainer()->hasParameter($name);
    }

    public function setParameter(string $name, mixed $value): void
    {
        $this->getPublicContainer()->setParameter($name, $value);
    }

    public function set(string $id, mixed $service): void
    {
        $container = $this->getPublicContainer();
        $renamedId = $this->renamedIds[$id] ?? $id;

        if (isset($this->nonSharedServices[$renamedId])) {
            if (!$service instanceof \Closure) {
                throw new InvalidArgumentException(\sprintf('The "%s" service is non-shared and must be replaced by a closure that should act as a factory.', $id));
            }
            $container->factories[$renamedId] = $container->factories['service_container'][$renamedId] = $service;

            return;
        }

        if (!$this->getPrivateContainer()->has($renamedId)) {
            $container->set($renamedId, $service);
        } elseif (isset($container->privates[$renamedId])) {
            throw new InvalidArgumentException(\sprintf('The "%s" service is already initialized, you cannot replace it.', $id));
        } else {
            $container->privates[$renamedId] = $service;
        }
    }

    public function has(string $id): bool
    {
        return $this->getPublicContainer()->has($id) || $this->getPrivateContainer()->has($id);
    }

    public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE): ?object
    {
        return $this->getPrivateContainer()->has($id) ? $this->getPrivateContainer()->get($id) : $this->getPublicContainer()->get($id, $invalidBehavior);
    }