<commit_before><?php declare(strict_types = 1);

namespace Venta\Container\Exception;

use Interop\Container\Exception\ContainerException as ContainerExceptionInterface;
use ReflectionFunctionAbstract;
use ReflectionParameter;
use RuntimeException;

/**
 * Class ResolveException
 *
 * @package Venta\Container\Exception
 */
class ArgumentResolveException extends RuntimeException implements ContainerExceptionInterface
{

    /**
     * @var ReflectionFunctionAbstract
     */
    private $function;

    /**
     * @var ReflectionParameter
     */
    private $parameter;

    /**
     * ArgumentResolveException constructor.
     *
     * @param ReflectionParameter $parameter
     * @param ReflectionFunctionAbstract $function
     * @param null $previous
     */
    public function __construct(ReflectionParameter $parameter, ReflectionFunctionAbstract $function, $previous = null)
    {
        parent::__construct(sprintf(
            'Unable to resolve parameter "%s" value for "%s" function (method).',
            $parameter->getName(),
            $function->getName()
        ), 0, $previous);

        $this->parameter = $parameter;
        $this->function = $function;
    }

    /**
     * @return ReflectionFunctionAbstract
     */
    public function getFunction(): ReflectionFunctionAbstract
    {
        return $this->function;
    }

    /**
     * @return ReflectionParameter
     */
    public function getParameter(): ReflectionParameter
    {
        return $this->parameter;
    }

}<commit_msg>Argument resolve exception made more verbose.<commit_after><?php declare(strict_types = 1);

namespace Venta\Container\Exception;

use Interop\Container\Exception\ContainerException as ContainerExceptionInterface;
use ReflectionFunctionAbstract;
use ReflectionMethod;
use ReflectionParameter;
use RuntimeException;

/**
 * Class ResolveException
 *
 * @package Venta\Container\Exception
 */
class ArgumentResolveException extends RuntimeException implements ContainerExceptionInterface
{

    /**
     * @var ReflectionFunctionAbstract
     */
    private $function;

    /**
     * @var ReflectionParameter
     */
    private $parameter;

    /**
     * ArgumentResolveException constructor.
     *
     * @param ReflectionParameter $parameter
     * @param ReflectionFunctionAbstract $function
     * @param null $previous
     */
    public function __construct(ReflectionParameter $parameter, ReflectionFunctionAbstract $function, $previous = null)
    {
        parent::__construct(sprintf(
            'Unable to resolve parameter "%s" value for "%s" %s.',
            $this->formatParameter($parameter),
            $this->formatFunction($function),
            $function instanceof ReflectionMethod ? 'method' : 'function'
        ), 0, $previous);

        $this->parameter = $parameter;
        $this->function = $function;
    }

    /**
     * @return ReflectionFunctionAbstract
     */
    public function getFunction(): ReflectionFunctionAbstract
    {
        return $this->function;
    }

    /**
     * @return ReflectionParameter
     */
    public function getParameter(): ReflectionParameter
    {
        return $this->parameter;
    }

    /**
     * Formats function declaration depending on method/function type.
     *
     * @param ReflectionFunctionAbstract $function
     * @return string
     */
    private function formatFunction(ReflectionFunctionAbstract $function)
    {
        return $function instanceof ReflectionMethod ?
            $function->getDeclaringClass()->getName() . '::' . $function->getName() :
            $function->getName();
    }

    /**
     * Formats parameter depending on type
     *
     * @param ReflectionParameter $parameter
     * @return string
     */
    private function formatParameter(ReflectionParameter $parameter): string
    {
        return $parameter->hasType() ?
            sprintf('%s $%s', $parameter->getType(), $parameter->getName()) :
            sprintf('$%s', $parameter->getName());
    }

}
{'fraction_non_alphanumeric': 0.10592055958031477, 'fraction_numerical': 0.0009992505620784412, 'mean_word_length': 2.91015625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '1679037', 'n_tokens_mistral': 983, 'n_tokens_neox': 972, 'n_words': 231}