<commit_before><?php

namespace Voelkel\DataTablesBundle\Table\Column;

use Voelkel\DataTablesBundle\Table\Filter\ChoiceFilter;
use Voelkel\DataTablesBundle\Table\Filter\TextFilter;

class Column
{
    /** @var string */
    private $name;

    /** @var string */
    private $field;

    /** @var \Voelkel\DataTablesBundle\Table\AbstractDataTable */
    private $table;

    public $filterRendered = false;

    /** @var \Voelkel\DataTablesBundle\Table\Filter\AbstractColumnFilter[] */
    private $filterInstances = [];

    private $filterBlockPrefixes = null;

    /** @deprecated  */
    const FILTER_NONE = false;
    /** @deprecated  */
    const FILTER_TEXT = 'text';
    /** @deprecated  */
    const FILTER_SELECT = 'select';

    const ORDER_ASCENDING = 'asc';
    const ORDER_DESCENDING = 'desc';

    /** @var array */
    private $options = [
        'visible' => true,
        'sortable' => true,
        'searchable' => true,
        'width' => null,
        'filter' => false, // false|'text'|'select' todo: |'bool'|'date'|'datetime'|'date_range'|'datetime_range'|\Voelkel\DataTablesBundle\Table\Filter\FilterInterface
        'filter_options' => [
            'popover' => false,
        ],
        'filter_choices' => [], // 'filter' => 'select' only
        'filter_query' => '%value%', // [%]value|split( |and)[%]
        'filter_attr' => [],
        'filter_empty' => false, // add a checkbox to filter empty resp null values
        'multiple' => false,
        'expanded' => false,
        'format_data_callback' => null, // function ($data, $entity, Column $column) {}
        'unbound' => false,
        'order' => null, // null|'asc'|'desc'
        'label' => null, // null|string|false
        'placeholder' => null, // null|string|false
        'abbr' => null,
    ];

    private $fields = [];

    public function __get($name)
    {
        if (!isset($this->fields[$name])) {
            return null;
        }

        if ('container' === $name) {
            @trigger_error(
                'The "container" property is deprecated. Use "$this->container" in column callbacks instead.',
                E_USER_DEPRECATED
            );
        }

        return $this->fields[$name];
    }

    public function __set($name, $value)
    {
        if ('container' !== $name) {
            throw new \Exception('magic setter is for deprecated fields only.');
        }

        $this->fields[$name] = $value;
    }

    /**
     * @param string $name
     * @param string $field
     * @param array $options
     */
    public function __construct($name, $field, array $options = [])
    {
        $this->name = $name;
        $this->field = $field;

        $this->options = array_merge($this->options, $options);

        if (false !== $this->options['filter']) {
            $this->options['searchable'] = true;
        }

        if (is_object($this->options['filter'])) {
            @trigger_error(
                'Using filter objects for option "filter" is deprecated. Use "FilterClass::class" instead.',
                E_USER_DEPRECATED
            );
        }

        if (self::FILTER_TEXT === $this->options['filter']) {
            $this->options['filter'] = TextFilter::class;
            $this->options['filter_options'] = array_merge([
                'filter_operator' => 'like',
                'filter_query' => $this->options['filter_query'],
            ], $this->options['filter_options']);
        } elseif (self::FILTER_SELECT === $this->options['filter']) {
            $this->options['filter'] = ChoiceFilter::class;
            $this->options['filter_options'] = array_merge([
                'choices' => $this->options['filter_choices'],
                'multiple' => $this->options['multiple'],
                'expanded' => $this->options['expanded'],
            ], $this->options['filter_options']);
        }
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;<commit_msg>fixed deprecated filter as object instance options.<commit_after><?php

namespace Voelkel\DataTablesBundle\Table\Column;

use Voelkel\DataTablesBundle\Table\Filter\ChoiceFilter;
use Voelkel\DataTablesBundle\Table\Filter\TextFilter;

class Column
{
    /** @var string */
    private $name;

    /** @var string */
    private $field;

    /** @var \Voelkel\DataTablesBundle\Table\AbstractDataTable */
    private $table;

    public $filterRendered = false;

    /** @var \Voelkel\DataTablesBundle\Table\Filter\AbstractColumnFilter[] */
    private $filterInstances = [];

    private $filterBlockPrefixes = null;

    /** @deprecated  */
    const FILTER_NONE = false;
    /** @deprecated  */
    const FILTER_TEXT = 'text';
    /** @deprecated  */
    const FILTER_SELECT = 'select';

    const ORDER_ASCENDING = 'asc';
    const ORDER_DESCENDING = 'desc';

    /** @var array */
    private $options = [
        'visible' => true,
        'sortable' => true,
        'searchable' => true,
        'width' => null,
        'filter' => false, // false|'text'|'select' todo: |'bool'|'date'|'datetime'|'date_range'|'datetime_range'|\Voelkel\DataTablesBundle\Table\Filter\FilterInterface
        'filter_options' => [
            'popover' => false,
        ],
        'filter_choices' => [], // 'filter' => 'select' only
        'filter_query' => '%value%', // [%]value|split( |and)[%]
        'filter_attr' => [],
        'filter_empty' => false, // add a checkbox to filter empty resp null values
        'multiple' => false,
        'expanded' => false,
        'format_data_callback' => null, // function ($data, $entity, Column $column) {}
        'unbound' => false,
        'order' => null, // null|'asc'|'desc'
        'label' => null, // null|string|false
        'placeholder' => null, // null|string|false
        'abbr' => null,
    ];

    private $fields = [];

    public function __get($name)
    {
        if (!isset($this->fields[$name])) {
            return null;
        }

        if ('container' === $name) {
            @trigger_error(
                'The "container" property is deprecated. Use "$this->container" in column callbacks instead.',
                E_USER_DEPRECATED
            );
        }

        return $this->fields[$name];
    }

    public function __set($name, $value)
    {
        if ('container' !== $name) {
            throw new \Exception('magic setter is for deprecated fields only.');
        }

        $this->fields[$name] = $value;
    }

    /**
     * @param string $name
     * @param string $field
     * @param array $options
     */
    public function __construct($name, $field, array $options = [])
    {
        $this->name = $name;
        $this->field = $field;

        $this->options = array_merge($this->options, $options);

        if (false !== $this->options['filter']) {
            $this->options['searchable'] = true;
        }

        if (is_object($this->options['filter'])) {
            @trigger_error(
                'Using filter objects for option "filter" is deprecated. Use "FilterClass::class" instead.',
                E_USER_DEPRECATED
            );

            if ($this->options['filter'] instanceof \Voelkel\DataTablesBundle\Table\Filter\AbstractColumnFilter) {
                $this->options['filter_options'] = array_merge($this->options['filter']->options, $this->options['filter_options']);
            }
        }

        if (self::FILTER_TEXT === $this->options['filter']) {
            $this->options['filter'] = TextFilter::class;
            $this->options['filter_options'] = array_merge([
                'filter_operator' => 'like',
                'filter_query' => $this->options['filter_query'],
            ], $this->options['filter_options']);
        } elseif (self::FILTER_SELECT === $this->options['filter']) {
            $this->options['filter'] = ChoiceFilter::class;
            $this->options['filter_options'] = array_merge([
                'choices' => $this->options['filter_choices'],
                'multiple' => $this->options['multiple'],
                'expanded' => $this->options['expanded'],
            ], $this->options['filter_options']);
        }
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
{'fraction_non_alphanumeric': 0.1643554805257446, 'fraction_numerical': 0.0, 'mean_word_length': 2.2209708737864076, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 106, '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': '2722800', 'n_tokens_mistral': 2434, 'n_tokens_neox': 2367, 'n_words': 478}