<commit_before><?php

/*
 * 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.
 */

namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Workflow\Workflow;

/**
 * @author <NAME> <<EMAIL>>
 */
class ExtensionPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if (!class_exists('Symfony\Component\Asset\Packages')) {
            $container->removeDefinition('twig.extension.assets');
        }

        if (!class_exists('Symfony\Component\ExpressionLanguage\Expression')) {
            $container->removeDefinition('twig.extension.expression');
        }

        if (!interface_exists('Symfony\Component\Routing\Generator\UrlGeneratorInterface')) {
            $container->removeDefinition('twig.extension.routing');
        }

        if (!class_exists('Symfony\Component\Yaml\Yaml')) {
            $container->removeDefinition('twig.extension.yaml');
        }

        if ($container->has('form.extension')) {
            $container->getDefinition('twig.extension.form')->addTag('twig.extension');
            $reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');

            $coreThemePath = \dirname(\dirname($reflClass->getFileName())).'/Resources/views/Form';
            $container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', [$coreThemePath]);

            $paths = $container->getDefinition('twig.template_iterator')->getArgument(2);
            $paths[$coreThemePath] = null;
            $container->getDefinition('twig.template_iterator')->replaceArgument(2, $paths);

            if ($container->hasDefinition('twig.cache_warmer')) {
                $paths = $container->getDefinition('twig.cache_warmer')->getArgument(2);
                $paths[$coreThemePath] = null;
                $container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths);
            }
        }<commit_msg>Simplify usage of dirname()<commit_after><?php

/*
 * 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.
 */

namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Workflow\Workflow;

/**
 * @author <NAME> <<EMAIL>>
 */
class ExtensionPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if (!class_exists('Symfony\Component\Asset\Packages')) {
            $container->removeDefinition('twig.extension.assets');
        }

        if (!class_exists('Symfony\Component\ExpressionLanguage\Expression')) {
            $container->removeDefinition('twig.extension.expression');
        }

        if (!interface_exists('Symfony\Component\Routing\Generator\UrlGeneratorInterface')) {
            $container->removeDefinition('twig.extension.routing');
        }

        if (!class_exists('Symfony\Component\Yaml\Yaml')) {
            $container->removeDefinition('twig.extension.yaml');
        }

        if ($container->has('form.extension')) {
            $container->getDefinition('twig.extension.form')->addTag('twig.extension');
            $reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');

            $coreThemePath = \dirname($reflClass->getFileName(), 2).'/Resources/views/Form';
            $container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', [$coreThemePath]);

            $paths = $container->getDefinition('twig.template_iterator')->getArgument(2);
            $paths[$coreThemePath] = null;
            $container->getDefinition('twig.template_iterator')->replaceArgument(2, $paths);

            if ($container->hasDefinition('twig.cache_warmer')) {
                $paths = $container->getDefinition('twig.cache_warmer')->getArgument(2);
                $paths[$coreThemePath] = null;
                $container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths);
            }
        }
{'fraction_non_alphanumeric': 0.13766730401529637, 'fraction_numerical': 0.0019120458891013384, 'mean_word_length': 3.5095785440613025, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 53, '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': '816449', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1227, 'n_words': 184}