<commit_before><?php

namespace Jasny\FormBuilder;

use Jasny\FormBuilder;

/**
 * Base class for HTML elements.
 */
abstract class Element
{
    /**
     * Decorators
     * @var Decorator[]
     */
    protected $decorators = [];
    
    /**
     * Disabled decorators
     * @var array
     */
    protected $disabledDecorators = [];
    
    /**
     * Parent element
     * @var Group
     */
    protected $parent;
    
    /**
     * HTML attributes
     * @var Attr
     */
    public $attr = [];
    
    /**
     * Element options
     * @var array
     */
    protected $options = [];
    
    
    /**
     * Class constructor.
     * 
     * @param array $options  Element options
     * @param array $attr     HTML attributes
     */
    public function __construct(array $options=[], array $attr=[])
    {
        if (isset($options['id'])) $attr['id'] = $options['id'];
        if (isset($options['name'])) $attr['name'] = $options['name'];
        unset($options['id'], $options['name']);
        
        $this->attr = new Attr($attr + $this->attr);
        $this->options = array_merge($this->options, $options);
    }
    
    
    /**
     * Add a decorator to the element.
     * 
     * @param Decorator|string $decorator  Decorator object or name
     * @param array            $options
     * @return Element  $this
     */
    public function addDecorator($decorator, array $options=[])<commit_msg>Fix element name option Only set attribute for control<commit_after><?php

namespace Jasny\FormBuilder;

use Jasny\FormBuilder;

/**
 * Base class for HTML elements.
 */
abstract class Element
{
    /**
     * Decorators
     * @var Decorator[]
     */
    protected $decorators = [];
    
    /**
     * Disabled decorators
     * @var array
     */
    protected $disabledDecorators = [];
    
    /**
     * Parent element
     * @var Group
     */
    protected $parent;
    
    /**
     * HTML attributes
     * @var Attr
     */
    public $attr = [];
    
    /**
     * Element options
     * @var array
     */
    protected $options = [];
    
    
    /**
     * Class constructor.
     * 
     * @param array $options  Element options
     * @param array $attr     HTML attributes
     */
    public function __construct(array $options=[], array $attr=[])
    {
        if (isset($options['id'])) $attr['id'] = $options['id'];
        unset($options['id']);
        
        $this->attr = new Attr($attr + $this->attr);
        $this->options = array_merge($this->options, $options);
    }
    
    
    /**
     * Add a decorator to the element.
     * 
     * @param Decorator|string $decorator  Decorator object or name
     * @param array            $options
     * @return Element  $this
     */
    public function addDecorator($decorator, array $options=[])
{'fraction_non_alphanumeric': 0.14311206281227695, 'fraction_numerical': 0.0, 'mean_word_length': 1.9046632124352332, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5916667', 'n_tokens_mistral': 831, 'n_tokens_neox': 830, 'n_words': 204}