<commit_before><?php

namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;

/*
 * This file is part of the Symfony package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/**
 * Adds all services with the tag "form.type" as argument
 * to the "form.type.loader.tagged" service
 *
 * @author <NAME> <<EMAIL>>
 */
class AddFormTypesPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('form.type.loader.tagged')) {
            return;
        }

        // Builds an array with service IDs as keys and tag aliases as values
        $types = array_map(function ($arguments) {
            if (!isset($arguments[0]['alias'])) {
                // TODO throw exception
            }

            return $arguments[0]['alias'];
        }, $container->findTaggedServiceIds('form.type'));

        // Flip, because we want tag aliases (= type identifiers) as keys
        $types = array_flip($types);

        $container->getDefinition('form.type.loader.tagged')->setArgument(1, $types);
    }
}<commit_msg>[FrameworkBundle] AddFormTypesPass now uses the service ID as alias if no alias is given<commit_after><?php

namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;

/*
 * This file is part of the Symfony package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/**
 * Adds all services with the tag "form.type" as argument
 * to the "form.type.loader.tagged" service
 *
 * @author <NAME> <<EMAIL>>
 */
class AddFormTypesPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('form.type.loader.tagged')) {
            return;
        }

        // Builds an array with service IDs as keys and tag aliases as values
        $types = array();
        $tags = $container->findTaggedServiceIds('form.type');

        foreach ($tags as $serviceId => $arguments) {
            $alias = isset($arguments[0]['alias'])
                ? $arguments[0]['alias']
                : $serviceId;

            // Flip, because we want tag aliases (= type identifiers) as keys
            $types[$alias] = $serviceId;
        }

        $container->getDefinition('form.type.loader.tagged')->setArgument(1, $types);
    }
}
{'fraction_non_alphanumeric': 0.11704019921736036, 'fraction_numerical': 0.0021344717182497333, 'mean_word_length': 3.07536231884058, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '364648', 'n_tokens_mistral': 763, 'n_tokens_neox': 741, 'n_words': 219}