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

Code before:
        $decoratorAttributes = $reflectionClass->getAttributes(AsDecorator::class, \ReflectionAttribute::IS_INSTANCEOF);
        $tagDecoratorAttributes = $reflectionClass->getAttributes(AsTagDecorator::class, \ReflectionAttribute::IS_INSTANCEOF);

        if (!$decoratorAttributes && !$tagDecoratorAttributes) {
            return;
        }

        if ($decoratorAttributes) {
            if (1 === \count($decoratorAttributes) && !$tagDecoratorAttributes) {
                $attribute = $decoratorAttributes[0]->newInstance();
                $definition->setDecoratedService($attribute->decorates, null, $attribute->priority, $attribute->onInvalid);

                return;
            }

            foreach ($decoratorAttributes as $attribute) {
                $attribute = $attribute->newInstance();

                $clonedDefinition = clone $definition;
                $clonedDefinition->setDecoratedService($attribute->decorates, null, $attribute->priority, $attribute->onInvalid);
                $container->setDefinition(\sprintf('.decorator.%s.%s', $attribute->decorates, $id), $clonedDefinition);
            }
        }

        if ($tagDecoratorAttributes) {
            foreach ($tagDecoratorAttributes as $attribute) {
                $attribute = $attribute->newInstance();

                $clonedDefinition = clone $definition;
                $tagAttributes = [
                    'decorates_tag' => $attribute->tag,
                    'priority' => $attribute->priority,
                ];

                if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $attribute->onInvalid) {
                    $tagAttributes['on_invalid'] = $attribute->onInvalid;
                }

                $clonedDefinition->addResourceTag('container.tag_decorator', $tagAttributes);
                $container->setDefinition(\sprintf('.tag_decorator.%s.%s', $attribute->tag, $id), $clonedDefinition);
            }
        }

        $container->removeDefinition($id);
    }
}


Review comment (suggestion):
```suggestion
        foreach ($tagDecoratorAttributes as $attribute) {
```

Code after:
        $decoratorAttributes = $reflectionClass->getAttributes(AsDecorator::class, \ReflectionAttribute::IS_INSTANCEOF);
        $tagDecoratorAttributes = $reflectionClass->getAttributes(AsTagDecorator::class, \ReflectionAttribute::IS_INSTANCEOF);

        if (!$decoratorAttributes && !$tagDecoratorAttributes) {
            return;
        }

        if (1 === \count($decoratorAttributes) && !$tagDecoratorAttributes) {
            $attribute = $decoratorAttributes[0]->newInstance();
            $definition->setDecoratedService($attribute->decorates, null, $attribute->priority, $attribute->onInvalid);

            return;
        }

        foreach ($decoratorAttributes as $attribute) {
            $attribute = $attribute->newInstance();

            $clonedDefinition = clone $definition;
            $clonedDefinition->setDecoratedService($attribute->decorates, null, $attribute->priority, $attribute->onInvalid);
            $container->setDefinition(\sprintf('.decorator.%s.%s', $attribute->decorates, $id), $clonedDefinition);
        }

        foreach ($tagDecoratorAttributes as $attribute) {
            $attribute = $attribute->newInstance();

            $clonedDefinition = clone $definition;
            $tagAttributes = [
                'decorates_tag' => $attribute->tag,
                'priority' => $attribute->priority,
            ];

            if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $attribute->onInvalid) {
                $tagAttributes['on_invalid'] = $attribute->onInvalid;
            }

            $clonedDefinition->addResourceTag('container.tag_decorator', $tagAttributes);
            $container->setDefinition(\sprintf('.tag_decorator.%s.%s', $attribute->tag, $id), $clonedDefinition);
        }

        $container->removeDefinition($id);
    }
}