Repository: symfony/symfony
File: src/Symfony/Component/DependencyInjection/ContainerBuilder.php (PHP)

Code before:
    }

    /**
     * Returns service ids for a given tag, asserting they have the "container.excluded" tag.
     *
     *  Example:
     *
     *      $container->register('foo')->addExcludeTag('my.tag', ['hello' => 'world'])
     *
     *      $serviceIds = $container->findExcludedServiceIds('my.tag');
     *      foreach ($serviceIds as $serviceId => $tags) {
     *          foreach ($tags as $tag) {
     *              echo $tag['hello'];
     *          }
     *      }
     *
     * @return array<string, array> An array of tags with the tagged service as key, holding a list of attribute arrays
     */
    public function findExcludedServiceIds(string $tagName): array
    {
        $this->usedTags[] = $tagName;
        $tags = [];
        foreach ($this->getDefinitions() as $id => $definition) {
            if ($definition->hasTag($tagName)) {
                if (!$definition->hasTag('container.excluded')) {
                    throw new InvalidArgumentException(\sprintf('The service "%s" tagged "%s" must have the "container.excluded" tag.', $id, $tagName));
                }
                $tags[$id] = $definition->getTag($tagName);
            }
        }

        return $tags;
    }

    /**
     * Returns all tags the defined services use.
     *
     * @return string[]
     */
    public function findTags(): array
    {
        $tags = [];
        foreach ($this->getDefinitions() as $id => $definition) {
            $tags[] = array_keys($definition->getTags());
        }

        return array_unique(array_merge([], ...$tags));
    }

    /**
     * Returns all tags not queried by findTaggedServiceIds.

Review comment (suggestion):
```suggestion
                    throw new InvalidArgumentException(\sprintf('The service "%s" tagged "%s" is missing the "container.excluded" tag.', $id, $tagName));
```

Code after:
    }

    /**
     * Returns service ids for a given tag, asserting they have the "container.excluded" tag.
     *
     *  Example:
     *
     *      $container->register('foo')->addExcludeTag('my.tag', ['hello' => 'world'])
     *
     *      $serviceIds = $container->findExcludedServiceIds('my.tag');
     *      foreach ($serviceIds as $serviceId => $tags) {
     *          foreach ($tags as $tag) {
     *              echo $tag['hello'];
     *          }
     *      }
     *
     * @return array<string, array> An array of tags with the tagged service as key, holding a list of attribute arrays
     */
    public function findExcludedServiceIds(string $tagName): array
    {
        $this->usedTags[] = $tagName;
        $tags = [];
        foreach ($this->getDefinitions() as $id => $definition) {
            if ($definition->hasTag($tagName)) {
                if (!$definition->hasTag('container.excluded')) {
                    throw new InvalidArgumentException(\sprintf('The service "%s" tagged "%s" is missing the "container.excluded" tag.', $id, $tagName));
                }
                $tags[$id] = $definition->getTag($tagName);
            }
        }

        return $tags;
    }

    /**
     * Returns all tags the defined services use.
     *
     * @return string[]
     */
    public function findTags(): array
    {
        $tags = [];
        foreach ($this->getDefinitions() as $id => $definition) {
            $tags[] = array_keys($definition->getTags());
        }

        return array_unique(array_merge([], ...$tags));
    }

    /**
     * Returns all tags not queried by findTaggedServiceIds.