<commit_before><?php

/*
 * This file is part of the Sami utility.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Sami\Parser;

class CodeParser
{
    protected $parser;
    protected $traverser;
    protected $context;
    protected $passCode;

    public function __construct(ParserContext $context, \PHPParser_Parser $parser, \PHPParser_NodeTraverser $traverser)
    {
        $this->context = $context;
        $this->parser = $parser;
        $this->traverser = $traverser;

        // hack for a BC break between PHPParser 0.9.1 and 0.9.2
        // the Parser::parse() method argument changed
        $m = new \ReflectionMethod($this->parser, 'parse');
        $parameters = $m->getParameters();
        $this->passCode = null === $parameters[0]->getClass();
    }

    public function getContext()
    {
        return $this->context;
    }

    public function parse($code)
    {
        try {
            if ($this->passCode) {<commit_msg>Increasing Xdebug nesting level during parsing<commit_after><?php

/*
 * This file is part of the Sami utility.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Sami\Parser;

class CodeParser
{
    protected $parser;
    protected $traverser;
    protected $context;
    protected $passCode;

    public function __construct(ParserContext $context, \PHPParser_Parser $parser, \PHPParser_NodeTraverser $traverser)
    {
        $this->context = $context;
        $this->parser = $parser;
        $this->traverser = $traverser;

        // hack for a BC break between PHPParser 0.9.1 and 0.9.2
        // the Parser::parse() method argument changed
        $m = new \ReflectionMethod($this->parser, 'parse');
        $parameters = $m->getParameters();
        $this->passCode = null === $parameters[0]->getClass();

        // with big fluent interfaces it can happen that PHP-Parser's Traverser
        // exceeds the 100 recursions limit; we set it to 10000 to be sure.
        ini_set('xdebug.max_nesting_level', 10000);
    }

    public function getContext()
    {
        return $this->context;
    }

    public function parse($code)
    {
        try {
            if ($this->passCode) {
{'fraction_non_alphanumeric': 0.1173728813559322, 'fraction_numerical': 0.011440677966101695, 'mean_word_length': 2.593607305936073, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '7118522', 'n_tokens_mistral': 714, 'n_tokens_neox': 687, 'n_words': 216}