<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;

use Sami\Parser\Filter\FilterInterface;
use Sami\Reflection\ClassReflection;

class ParserContext
{
    protected $filter;
    protected $docBlockParser;
    protected $prettyPrinter;
    protected $errors;
    protected $namespace;
    protected $aliases;
    protected $class;
    protected $file;
    protected $hash;
    protected $classes;

    public function __construct(FilterInterface $filter, DocBlockParser $docBlockParser, $prettyPrinter)
    {
        $this->filter = $filter;
        $this->docBlockParser = $docBlockParser;
        $this->prettyPrinter = $prettyPrinter;
    }

    public function getFilter()
    {
        return $this->filter;
    }

    public function getDocBlockParser()
    {
        return $this->docBlockParser;
    }

    public function getPrettyPrinter()
    {
        return $this->prettyPrinter;
    }

    public function addAlias($alias, $name)
    {
        $this->aliases[$alias] = $name;
    }

    public function getAliases()
    {
        return $this->aliases;
    }

    public function enterFile($file, $hash)
    {
        $this->file = $file;
        $this->hash = $hash;
        $this->errors = array();
        $this->classes = array();
    }

    public function leaveFile()
    {
        $this->hash = null;
        $this->file = null;
        $this->errors = array();

        return $this->classes;
    }

    public function getHash()
    {
        return $this->hash;
    }

    public function getFile()
    {
        return $this->file;
    }

    public function addErrors($name, $line, array $errors)
    {
        foreach ($errors as $error) {
            $this->addError($name, $line, $error);
        }
    }

    public function addError($name, $line, $error)
    {
        $this->errors[] = sprintf('An error occurred while parsing "%s" line "%d": %s', $name, $line, $error);
    }

    public function getErrors()
    {
        return $this->errors;
    }

    public function enterClass(ClassReflection $class)
    {
        $this->class = $class;
    }

    public function leaveClass()<commit_msg>updated the error message for phpdocs issues to include the file name<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;

use Sami\Parser\Filter\FilterInterface;
use Sami\Reflection\ClassReflection;

class ParserContext
{
    protected $filter;
    protected $docBlockParser;
    protected $prettyPrinter;
    protected $errors;
    protected $namespace;
    protected $aliases;
    protected $class;
    protected $file;
    protected $hash;
    protected $classes;

    public function __construct(FilterInterface $filter, DocBlockParser $docBlockParser, $prettyPrinter)
    {
        $this->filter = $filter;
        $this->docBlockParser = $docBlockParser;
        $this->prettyPrinter = $prettyPrinter;
    }

    public function getFilter()
    {
        return $this->filter;
    }

    public function getDocBlockParser()
    {
        return $this->docBlockParser;
    }

    public function getPrettyPrinter()
    {
        return $this->prettyPrinter;
    }

    public function addAlias($alias, $name)
    {
        $this->aliases[$alias] = $name;
    }

    public function getAliases()
    {
        return $this->aliases;
    }

    public function enterFile($file, $hash)
    {
        $this->file = $file;
        $this->hash = $hash;
        $this->errors = array();
        $this->classes = array();
    }

    public function leaveFile()
    {
        $this->hash = null;
        $this->file = null;
        $this->errors = array();

        return $this->classes;
    }

    public function getHash()
    {
        return $this->hash;
    }

    public function getFile()
    {
        return $this->file;
    }

    public function addErrors($name, $line, array $errors)
    {
        foreach ($errors as $error) {
            $this->addError($name, $line, $error);
        }
    }

    public function addError($name, $line, $error)
    {
        $this->errors[] = sprintf('%s on "%s" in %s:%d', $error, $name, $this->file, $line);
    }

    public function getErrors()
    {
        return $this->errors;
    }

    public function enterClass(ClassReflection $class)
    {
        $this->class = $class;
    }

    public function leaveClass()
{'fraction_non_alphanumeric': 0.12280325760822974, 'fraction_numerical': 0.0, 'mean_word_length': 2.3335714285714286, 'pattern_counts': {'":': 1, '<': 11, '<?xml version=': 0, '>': 54, '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': '3600789', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1366, 'n_words': 361}