<commit_before><?php
/**
 * Vision PHP-Framework
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2012-2013 <NAME>
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 */
namespace Vision\Form;

use Vision\DataStructures\Tree\Node;
use Vision\DataStructures\Tree\NodeIterator;

/**
 * Form
 *
 * @author <NAME> <<EMAIL>>
 */
class Form extends AbstractCompositeType
{
    /** @type array $attributes */
    protected $attributes = array(
        'action' => '',
        'enctype' => 'multipart/form-data',
        'method' => 'post'
    );

    /** @type array */
    protected $data = array();

    /** @type array $errors */
    protected $errors = array();

    /** @type array $values */
    protected $values = array();

    /** @type \RecursiveIteratorIterator|null $iterator */
    protected $iterator = null;

    /**
     * Constructor
     *
     * @param string $name
     */
    public function __construct($name)
    {
        parent::__construct($name);

        $this->setTag('form');

        $node = new Node;
        $node->addChild($this);
        $this->iterator = new \RecursiveIteratorIterator(new NodeIterator($node), \RecursiveIteratorIterator::CHILD_FIRST);
    }

    /**
     * @return \RecursiveIteratorIterator
     */
    public function getIterator()
    {
        return $this->iterator;
    }

    /**
     * @param string $action
     *
     * @return Form Provides a fluent interface.
     */
    public function setAction($action)
    {
        $this->setAttribute('action', $action);
        return $this;
    }

    /**
     * @api
     *
     * @param array $data
     *
     * @return Form Provides a fluent interface.
     */
    public function setValues(array $data)
    {
        $iterator = $this->getIterator();

        foreach ($iterator as $element) {
            $name = $element->getName();
            if (isset($data[$name])) {
                $element->setValue($data[$name]);
            }
        }

        return $this;
    }

    /**
     * @api
     *
     * @return array
     */
    public function getValues()
    {<commit_msg>Fix: apply setValues() only to controls<commit_after><?php
/**
 * Vision PHP-Framework
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2012-2013 <NAME>
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 */
namespace Vision\Form;

use Vision\DataStructures\Tree\Node;
use Vision\DataStructures\Tree\NodeIterator;

/**
 * Form
 *
 * @author <NAME> <<EMAIL>>
 */
class Form extends AbstractCompositeType
{
    /** @type array $attributes */
    protected $attributes = array(
        'action' => '',
        'enctype' => 'multipart/form-data',
        'method' => 'post'
    );

    /** @type array */
    protected $data = array();

    /** @type array $errors */
    protected $errors = array();

    /** @type array $values */
    protected $values = array();

    /** @type \RecursiveIteratorIterator|null $iterator */
    protected $iterator = null;

    /**
     * Constructor
     *
     * @param string $name
     */
    public function __construct($name)
    {
        parent::__construct($name);

        $this->setTag('form');

        $node = new Node;
        $node->addChild($this);
        $this->iterator = new \RecursiveIteratorIterator(new NodeIterator($node), \RecursiveIteratorIterator::CHILD_FIRST);
    }

    /**
     * @return \RecursiveIteratorIterator
     */
    public function getIterator()
    {
        return $this->iterator;
    }

    /**
     * @param string $action
     *
     * @return Form Provides a fluent interface.
     */
    public function setAction($action)
    {
        $this->setAttribute('action', $action);
        return $this;
    }

    /**
     * @api
     *
     * @param array $data
     *
     * @return Form Provides a fluent interface.
     */
    public function setValues(array $data)
    {
        $iterator = $this->getIterator();

        foreach ($iterator as $element) {
            if ($element instanceof Control\AbstractControl) {
                $name = $element->getName();
                if (isset($data[$name])) {
                    $element->setValue($data[$name]);
                }
            }
        }

        return $this;
    }

    /**
     * @api
     *
     * @return array
     */
    public function getValues()
    {
{'fraction_non_alphanumeric': 0.15019671372367507, 'fraction_numerical': 0.0037028465632955336, 'mean_word_length': 2.050105857445307, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2232648', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1245, 'n_words': 277}