<commit_before><?php

namespace JMS\Payment\CoreBundle\DependencyInjection\Compiler;

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

/**
 * Wires payment method types.
 *
 * @author <NAME> <<EMAIL>>
 */
class AddPaymentMethodFormTypesPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        $paymentMethodFormTypes = array();
        foreach ($container->findTaggedServiceIds('payment.method_form_type') as $id => $attributes) {
            $definition = $container->getDefinition($id);

            // check that this definition is also registered as a form type
            $attributes = $definition->getTag('form.type');
            if (!$attributes) {
                throw new \RuntimeException(sprintf('The service "%s" is marked as payment method form type (tagged with "payment.method_form_type"), but is not registered as a form type with the Form Component. Please also add a "form.type" tag.', $id));
            }

            if (!isset($attributes[0]['alias'])) {
                throw new \RuntimeException(sprintf('Please define an alias attribute for tag "form.type" of service "%s".', $id));
            }

            $paymentMethodFormTypes[] = $attributes[0]['alias'];
        }

        $container->getDefinition('payment.form.choose_payment_method_type')
            ->addArgument($paymentMethodFormTypes);
    }
}<commit_msg>fixed error when form type is not available<commit_after><?php

namespace JMS\Payment\CoreBundle\DependencyInjection\Compiler;

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

/**
 * Wires payment method types.
 *
 * @author <NAME> <<EMAIL>>
 */
class AddPaymentMethodFormTypesPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('payment.form.choose_payment_method_type')) {
            return;
        }
        
        $paymentMethodFormTypes = array();
        foreach ($container->findTaggedServiceIds('payment.method_form_type') as $id => $attributes) {
            $definition = $container->getDefinition($id);

            // check that this definition is also registered as a form type
            $attributes = $definition->getTag('form.type');
            if (!$attributes) {
                throw new \RuntimeException(sprintf('The service "%s" is marked as payment method form type (tagged with "payment.method_form_type"), but is not registered as a form type with the Form Component. Please also add a "form.type" tag.', $id));
            }

            if (!isset($attributes[0]['alias'])) {
                throw new \RuntimeException(sprintf('Please define an alias attribute for tag "form.type" of service "%s".', $id));
            }

            $paymentMethodFormTypes[] = $attributes[0]['alias'];
        }

        $container->getDefinition('payment.form.choose_payment_method_type')
            ->addArgument($paymentMethodFormTypes);
    }
}
{'fraction_non_alphanumeric': 0.11511479591836735, 'fraction_numerical': 0.0012755102040816326, 'mean_word_length': 3.1882510013351135, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 22, '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': '3138601', 'n_tokens_mistral': 788, 'n_tokens_neox': 778, 'n_words': 210}