<commit_before><?php declare(strict_types=1);

namespace Compolomus\LSQLQueryBuilder\Parts;

use Compolomus\LSQLQueryBuilder\System\{
    Traits\Helper,
    Traits\GetParts,
    Traits\Join as TJoin,
    Traits\Limit as TLimit,
    Traits\Where as TWhere,
    Traits\Order as TOrder,
    Traits\Group as TGroup,
    Traits\Caller,
    Fields
};

/**
 * @method string table()
 */
class Select
{
    use TJoin, TLimit, TWhere, TOrder, TGroup, Caller, GetParts, Helper;

    private $fields = [];

    public function __construct(array $fields = ['*'])
    {
        foreach ($fields as $allias => $column) {
            preg_match("#(?<fieldName>.*)\|(?<function>.*)#", $column, $matches);
            if (count($matches)) {
                $field = $matches['fieldName'];
                $object = $this->fields[$field] = new Fields($field);
                $object->setFunction($matches['function']);
            } else {
                $object = $this->fields[$column] = new Fields($column);
            }
            if (!is_int($allias)) {
                $object->setAllias($allias);
            }
        }
    }

    public function setFunction(string $fieldName, string $function): Select
    {
        if (!in_array($fieldName, array_keys($this->fields))) {
            throw new \InvalidArgumentException('Не найдено поле ' . $fieldName . ' |SELECT setFunction|');
        }
        $this->fields[$fieldName]->setFunction($function);
        return $this;
    }

    public function setAllias(string $fieldName, string $allias): Select
    {
        $this->fields[$fieldName]->setAllias($allias);
        return $this;
    }

    public function getFields(): string
    {
        return $this->concat(array_map(function($field) {
            return $field->result();
        }, $this->fields));
    }

    public function get(): string
    {
        return 'SELECT ' . $this->getFields() . ' FROM '
            . $this->table()
            . (!is_null($this->join) ? $this->join->result() : '')
            . $this->getParts();
    }
}<commit_msg>Add type hint for array_map<commit_after><?php declare(strict_types=1);

namespace Compolomus\LSQLQueryBuilder\Parts;

use Compolomus\LSQLQueryBuilder\System\{
    Traits\Helper,
    Traits\GetParts,
    Traits\Join as TJoin,
    Traits\Limit as TLimit,
    Traits\Where as TWhere,
    Traits\Order as TOrder,
    Traits\Group as TGroup,
    Traits\Caller,
    Fields
};

/**
 * @method string table()
 */
class Select
{
    use TJoin, TLimit, TWhere, TOrder, TGroup, Caller, GetParts, Helper;

    private $fields = [];

    public function __construct(array $fields = ['*'])
    {
        foreach ($fields as $allias => $column) {
            preg_match("#(?<fieldName>.*)\|(?<function>.*)#", $column, $matches);
            if (count($matches)) {
                $field = $matches['fieldName'];
                $object = $this->fields[$field] = new Fields($field);
                $object->setFunction($matches['function']);
            } else {
                $object = $this->fields[$column] = new Fields($column);
            }
            if (!is_int($allias)) {
                $object->setAllias($allias);
            }
        }
    }

    public function setFunction(string $fieldName, string $function): Select
    {
        if (!in_array($fieldName, array_keys($this->fields))) {
            throw new \InvalidArgumentException('Не найдено поле ' . $fieldName . ' |SELECT setFunction|');
        }
        $this->fields[$fieldName]->setFunction($function);
        return $this;
    }

    public function setAllias(string $fieldName, string $allias): Select
    {
        $this->fields[$fieldName]->setAllias($allias);
        return $this;
    }

    public function getFields(): string
    {
        return $this->concat(array_map(function(Fields $field): string {
            return $field->result();
        }, $this->fields));
    }

    public function get(): string
    {
        return 'SELECT ' . $this->getFields() . ' FROM '
            . $this->table()
            . (!is_null($this->join) ? $this->join->result() : '')
            . $this->getParts();
    }
}
{'fraction_non_alphanumeric': 0.15560916767189384, 'fraction_numerical': 0.0004825090470446321, 'mean_word_length': 2.2568735271013356, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 45, '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': '6137483', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1224, 'n_words': 250}