<commit_before><?php

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

namespace CoopTilleuls\MigrationBundle\DependencyInjection;

use Doctrine\Common\Inflector\Inflector;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
 * @author <NAME> <<EMAIL>>
 */
final class MigrationCompilerPass implements CompilerPassInterface
{
    private $tag;
    private $locator;
    private $allowAlias;

    public function __construct($tag, $locator, $allowAlias = false)
    {
        $this->tag = $tag;
        $this->locator = $locator;
        $this->allowAlias = $allowAlias;
    }

    /**
     * {@inheritdoc}
     */
    public function process(ContainerBuilder $container)
    {
        $services = [];
        foreach ($container->findTaggedServiceIds($this->tag) as $id => $attributes) {
            $class = $container->getDefinition($id)->getClass();
            $reflection = new \ReflectionClass($class);
            $aliases = [
                $class,
                Inflector::tableize(preg_replace('/^(.*)Loader$/i', '$1', $reflection->getShortName())),
            ];
            if (true === $this->allowAlias && isset($attributes[0]['alias'])) {
                $aliases[] = $attributes[0]['alias'];
            }
            foreach (array_unique($aliases) as $alias) {
                $services[$alias] = new Reference($id);
            }
        }

        $container->getDefinition($this->locator)->replaceArgument(0, $services);
    }
}
<commit_msg>Update aliases process<commit_after><?php

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

namespace CoopTilleuls\MigrationBundle\DependencyInjection;

use Doctrine\Common\Inflector\Inflector;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
 * @author <NAME> <<EMAIL>>
 */
final class MigrationCompilerPass implements CompilerPassInterface
{
    private $tag;
    private $locator;
    private $allowAlias;

    public function __construct($tag, $locator, $allowAlias = false)
    {
        $this->tag = $tag;
        $this->locator = $locator;
        $this->allowAlias = $allowAlias;
    }

    /**
     * {@inheritdoc}
     */
    public function process(ContainerBuilder $container)
    {
        $services = [];
        foreach ($container->findTaggedServiceIds($this->tag) as $id => $attributes) {
            $class = $container->getDefinition($id)->getClass();
            $reflection = new \ReflectionClass($class);
            $alias = Inflector::tableize(preg_replace('/^(.*)Loader$/i', '$1', $reflection->getShortName()));
            $aliases = [$class, $alias, str_replace('_', '-', $alias)];
            if (true === $this->allowAlias && isset($attributes[0]['alias'])) {
                $aliases[] = $attributes[0]['alias'];
            }
            foreach (array_unique($aliases) as $alias) {
                $services[$alias] = new Reference($id);
            }
        }

        $container->getDefinition($this->locator)->replaceArgument(0, $services);
    }
}

{'fraction_non_alphanumeric': 0.1433370660694289, 'fraction_numerical': 0.0022396416573348264, 'mean_word_length': 2.935022026431718, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 41, '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': '2549225', 'n_tokens_mistral': 998, 'n_tokens_neox': 989, 'n_words': 212}