<commit_before><?php

namespace Oro\Bundle\LayoutBundle\Layout\Block\Type;

use Oro\Component\Layout\Block\OptionsResolver\OptionsResolver;
use Oro\Component\Layout\Block\Type\AbstractType;
use Oro\Component\Layout\Block\Type\Options;
use Oro\Component\Layout\BlockInterface;
use Oro\Component\Layout\BlockView;
use Oro\Component\Layout\Util\BlockUtils;

class InputType extends AbstractType
{
    const NAME = 'input';

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'type' => 'text'
        ]);
        $resolver->setDefined(
            [
                'id',
                'name',
                'value',
                'placeholder'
            ]
        );
    }

    /**
     * {@inheritdoc}
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        BlockUtils::setViewVarsFromOptions($view, $options, ['name', 'type', 'value', 'placeholder']);
        if (isset($options['id'])) {
            $view->vars['attr']['id'] = $options->get('id', false);
        }
    }

    public function finishView(BlockView $view, BlockInterface $block)
    {
        if(!$view->vars['name']) {
            unset($view->vars['name']);
        }
        if(!$view->vars['value']) {
            unset($view->vars['value']);
        }
        if(!$view->vars['placeholder']) {
            unset($view->vars['placeholder']);
        }
    }


    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return self::NAME;
    }
}
<commit_msg>BB-4325: Refactor block types, move expressions in vars from buildView to finishView - fixed test - cs fixes - removed BlockPrefixExtension because it's unnecessary, additional_block_prefixes used instead<commit_after><?php

namespace Oro\Bundle\LayoutBundle\Layout\Block\Type;

use Oro\Component\Layout\Block\OptionsResolver\OptionsResolver;
use Oro\Component\Layout\Block\Type\AbstractType;
use Oro\Component\Layout\Block\Type\Options;
use Oro\Component\Layout\BlockInterface;
use Oro\Component\Layout\BlockView;
use Oro\Component\Layout\Util\BlockUtils;

class InputType extends AbstractType
{
    const NAME = 'input';

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'type' => 'text'
            ]
        );
        $resolver->setDefined(
            [
                'id',
                'name',
                'value',
                'placeholder'
            ]
        );
    }

    /**
     * {@inheritdoc}
     */
    public function buildView(BlockView $view, BlockInterface $block, Options $options)
    {
        BlockUtils::setViewVarsFromOptions($view, $options, ['name', 'type', 'value', 'placeholder']);
        if (isset($options['id'])) {
            $view->vars['attr']['id'] = $options->get('id', false);
        }
    }

    public function finishView(BlockView $view, BlockInterface $block)
    {
        if (!$view->vars['name']) {
            unset($view->vars['name']);
        }
        if (!$view->vars['value']) {
            unset($view->vars['value']);
        }
        if (!$view->vars['placeholder']) {
            unset($view->vars['placeholder']);
        }
    }


    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return self::NAME;
    }
}

{'fraction_non_alphanumeric': 0.15081206496519722, 'fraction_numerical': 0.001160092807424594, 'mean_word_length': 2.1526508226691043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '7587769', 'n_tokens_mistral': 994, 'n_tokens_neox': 979, 'n_words': 172}