<commit_before><?php

/**
 * This file is part of the Zephir.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Zephir;

use Zephir\Exception\CompilerException;
use Zephir\Expression\Constants;
use Zephir\Expression\StaticConstantAccess;

/**
 * ClassConstant.
 *
 * Represents a class constant
 */
class ClassConstant
{
    /**
     * @var string
     */
    protected string $name;

    /**
     * @var array
     */
    protected array $value = [];

    /**
     * @var string|null
     */
    protected ?string $docblock = null;

    /**
     * ClassConstant constructor.
     *
     * @param string $name
     * @param array  $value
     * @param string|null $docBlock
     */
    public function __construct(string $name, array $value, ?string $docBlock = null)
    {
        $this->name = $name;
        $this->value = $value;
        $this->docblock = $docBlock;
    }

    /**
     * Returns the constant's name.
     *
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * Returns the constant's value.
     *
     * TODO: Rewrite name
     *
     * @return array
     */
    public function getValue(): array
    {
        return $this->value;
    }

    /**
     * Get the type of the value of the constant.
     *
     * @return string
     */
    public function getValueType(): string
    {
        return $this->value['type'];
    }

    /**
     * Get value of the value of the constant.
     *
     * @return mixed
     */
    public function getValueValue()
    {
        if (isset($this->value['value'])) {
            return $this->value['value'];
        }

        return false;
    }

    /**
     * Returns the docblock related to the constant.
     *
     * @return string
     */
    public function getDocBlock(): string
    {
        return $this->docblock;
    }

    /**
     * Get type of class constant.
     *
     * @return string
     */
    public function getType(): string
    {
        return $this->value['type'];
    }

    /**
     * Process the value of the class constant if needed.
     *
     * @param CompilationContext $compilationContext
     *
     * @throws Exception
     */
    public function processValue(CompilationContext $compilationContext)
    {
        if ('constant' === $this->value['type']) {
            $constant = new Constants();
            $compiledExpression = $constant->compile($this->value, $compilationContext);

            $this->value = [<commit_msg>#2213 - Fix return type of `getDocBlock()` method<commit_after><?php

/**
 * This file is part of the Zephir.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Zephir;

use Zephir\Exception\CompilerException;
use Zephir\Expression\Constants;
use Zephir\Expression\StaticConstantAccess;

/**
 * ClassConstant.
 *
 * Represents a class constant
 */
class ClassConstant
{
    /**
     * @var string
     */
    protected string $name;

    /**
     * @var array
     */
    protected array $value = [];

    /**
     * @var string|null
     */
    protected ?string $docblock = null;

    /**
     * ClassConstant constructor.
     *
     * @param string $name
     * @param array  $value
     * @param string|null $docBlock
     */
    public function __construct(string $name, array $value, ?string $docBlock = null)
    {
        $this->name = $name;
        $this->value = $value;
        $this->docblock = $docBlock;
    }

    /**
     * Returns the constant's name.
     *
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * Returns the constant's value.
     *
     * TODO: Rewrite name
     *
     * @return array
     */
    public function getValue(): array
    {
        return $this->value;
    }

    /**
     * Get the type of the value of the constant.
     *
     * @return string
     */
    public function getValueType(): string
    {
        return $this->value['type'];
    }

    /**
     * Get value of the value of the constant.
     *
     * @return mixed
     */
    public function getValueValue()
    {
        if (isset($this->value['value'])) {
            return $this->value['value'];
        }

        return false;
    }

    /**
     * Returns the docblock related to the constant.
     *
     * @return string|null
     */
    public function getDocBlock(): ?string
    {
        return $this->docblock;
    }

    /**
     * Get type of class constant.
     *
     * @return string
     */
    public function getType(): string
    {
        return $this->value['type'];
    }

    /**
     * Process the value of the class constant if needed.
     *
     * @param CompilationContext $compilationContext
     *
     * @throws Exception
     */
    public function processValue(CompilationContext $compilationContext)
    {
        if ('constant' === $this->value['type']) {
            $constant = new Constants();
            $compiledExpression = $constant->compile($this->value, $compilationContext);

            $this->value = [
{'fraction_non_alphanumeric': 0.12528387585162756, 'fraction_numerical': 0.000757002271006813, 'mean_word_length': 1.9182771949199338, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, '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': '629988', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1501, 'n_words': 418}