<commit_before><?php
namespace Vda\Query\Projection;

use Vda\Query\Alias;
use Vda\Query\Field;
use Vda\Util\BeanUtil;

class EntityProjection implements IProjection
{
    private $entityClass;
    private $fieldIndices;

    public function __construct($entityClass, $fields)
    {
        $this->entityClass = $entityClass;
        $this->fieldIndices = array();

        $entityFields = BeanUtil::listProperties($entityClass);
        foreach ($fields as $i => $field) {
            if ($field instanceof Field) {
                $name = $field->getName();
            } elseif ($field instanceof Alias) {
                $name = $field->getAlias();
            } else {
                continue;
            }

            if (in_array($name, $entityFields)) {
                $this->fieldIndices[$i] = $name;
            }
        }
    }

    public function project(array $tuple)
    {
        $result = new $this->entityClass;<commit_msg>Use correct property name in the entity mapping projection<commit_after><?php
namespace Vda\Query\Projection;

use Vda\Query\Alias;
use Vda\Query\Field;
use Vda\Util\BeanUtil;

class EntityProjection implements IProjection
{
    private $entityClass;
    private $fieldIndices;

    public function __construct($entityClass, $fields)
    {
        $this->entityClass = $entityClass;
        $this->fieldIndices = array();

        $entityFields = BeanUtil::listProperties($entityClass);
        foreach ($fields as $i => $field) {
            if ($field instanceof Field) {
                $name = $field->getPropertyName();
            } elseif ($field instanceof Alias) {
                $name = $field->getAlias();
            } else {
                continue;
            }

            if (in_array($name, $entityFields)) {
                $this->fieldIndices[$i] = $name;
            }
        }
    }

    public function project(array $tuple)
    {
        $result = new $this->entityClass;
{'fraction_non_alphanumeric': 0.119280205655527, 'fraction_numerical': 0.0, 'mean_word_length': 2.0839936608557843, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '7533762', 'n_tokens_mistral': 540, 'n_tokens_neox': 531, 'n_words': 123}