<commit_before><?php

declare(strict_types=1);

namespace Brick\Di;

/**
 * Exception thrown when a parameter/property could not be resolved.
 */
class UnresolvedValueException extends \RuntimeException
{
    /**
     * @param \ReflectionParameter $parameter
     *
     * @return UnresolvedValueException
     */
    public static function unresolvedParameter(\ReflectionParameter $parameter) : UnresolvedValueException
    {
        $message = 'The parameter "%s" from function "%s" could not be resolved';
        $message = sprintf($message, self::getParameterName($parameter), self::getFunctionName($parameter));

        return new self($message);
    }

    /**
     * @param \ReflectionProperty $property
     *
     * @return UnresolvedValueException
     */
    public static function unresolvedProperty(\ReflectionProperty $property) : UnresolvedValueException
    {
        $message = 'The property %s::$%s could not be resolved';
        $message = sprintf($message, $property->getDeclaringClass()->getName(), $property->getName());

        return new self($message);
    }

    /**
     * Returns the type (if any) + name of a function parameter.
     *
     * @param \ReflectionParameter $parameter
     *
     * @return string
     */
    private static function getParameterName(\ReflectionParameter $parameter) : string
    {
        return self::getTypeHint($parameter) . '$' . $parameter->getName();
    }

    /**
     * Helper class for getParameterName().
     *
     * @param \ReflectionParameter $parameter
     *
     * @return string
     */
    private static function getTypeHint(\ReflectionParameter $parameter) : string
    {
        if ($parameter->isArray()) {
            return 'array ';
        }

        $class = $parameter->getClass();
        if ($class) {
            return $class->getName() . ' ';
        }

        return '';
    }

    /**
     * Returns the type (if any) + name of a function.
     *
     * @param \ReflectionParameter $parameter
     *
     * @return string
     */
    private static function getFunctionName(\ReflectionParameter $parameter) : string
    {<commit_msg>Use ReflectionParameter::getType() for exception messages<commit_after><?php

declare(strict_types=1);

namespace Brick\Di;

/**
 * Exception thrown when a parameter/property could not be resolved.
 */
class UnresolvedValueException extends \RuntimeException
{
    /**
     * @param \ReflectionParameter $parameter
     *
     * @return UnresolvedValueException
     */
    public static function unresolvedParameter(\ReflectionParameter $parameter) : UnresolvedValueException
    {
        $message = 'The parameter "%s" from function "%s" could not be resolved';
        $message = sprintf($message, self::getParameterName($parameter), self::getFunctionName($parameter));

        return new self($message);
    }

    /**
     * @param \ReflectionProperty $property
     *
     * @return UnresolvedValueException
     */
    public static function unresolvedProperty(\ReflectionProperty $property) : UnresolvedValueException
    {
        $message = 'The property %s::$%s could not be resolved';
        $message = sprintf($message, $property->getDeclaringClass()->getName(), $property->getName());

        return new self($message);
    }

    /**
     * Returns the type (if any) + name of a function parameter.
     *
     * @param \ReflectionParameter $parameter
     *
     * @return string
     */
    private static function getParameterName(\ReflectionParameter $parameter) : string
    {
        $parameterType = '';

        if (null !== $type = $parameter->getType()) {
            $parameterType = (string) $type . ' ';
        }

        return $parameterType . '$' . $parameter->getName();
    }

    /**
     * Returns the type (if any) + name of a function.
     *
     * @param \ReflectionParameter $parameter
     *
     * @return string
     */
    private static function getFunctionName(\ReflectionParameter $parameter) : string
    {
{'fraction_non_alphanumeric': 0.11892839258888332, 'fraction_numerical': 0.000500751126690035, 'mean_word_length': 2.7093779015784585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '6866111', 'n_tokens_mistral': 1013, 'n_tokens_neox': 1004, 'n_words': 270}