<commit_before><?php
/*
 * This file licensed under the MIT license.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Swop\FilterExpressionParser\Bridge\Doctrine;

use Doctrine\ORM\QueryBuilder;
use Swop\FilterExpressionParser\Node\Node;

class QueryBuilderPatcher
{
    /** @var QueryExpressionBuilder */
    private $queryExpressionBuilder;

    public function __construct(QueryExpressionBuilder $queryExpressionBuilder)
    {
        $this->queryExpressionBuilder = $queryExpressionBuilder;
    }

    public function patch(QueryBuilder $qb, Node $filterAST, QueryContext $qc)
    {
        $queryExpression = $this->queryExpressionBuilder->buildQueryExpression($filterAST, $qc);

        $qb->andWhere($queryExpression);
        $qb->setParameters($qc->getParameters());

        return $qb;
    }
}<commit_msg>Fixes Doctrine qb parameters replacement (use override instead)<commit_after><?php
/*
 * This file licensed under the MIT license.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Swop\FilterExpressionParser\Bridge\Doctrine;

use Doctrine\ORM\QueryBuilder;
use Swop\FilterExpressionParser\Node\Node;

class QueryBuilderPatcher
{
    /** @var QueryExpressionBuilder */
    private $queryExpressionBuilder;

    public function __construct(QueryExpressionBuilder $queryExpressionBuilder)
    {
        $this->queryExpressionBuilder = $queryExpressionBuilder;
    }

    public function patch(QueryBuilder $qb, Node $filterAST, QueryContext $qc)
    {
        $queryExpression = $this->queryExpressionBuilder->buildQueryExpression($filterAST, $qc);

        $qb->andWhere($queryExpression);

        foreach ($qc->getParameters() as $key => $value) {
            $qb->setParameter($key, $value);
        }

        return $qb;
    }
}
{'fraction_non_alphanumeric': 0.10687405920722529, 'fraction_numerical': 0.0, 'mean_word_length': 3.8634146341463413, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 22, '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': '1680059', 'n_tokens_mistral': 550, 'n_tokens_neox': 532, 'n_words': 139}