protected function doValidate()
    {
        if ($this->argumentTypes === false) {
            throw new CallableFunctionValidatorException('Variable $argumentTypes must be defined.');
        }

        $argumentCount = count($this->argumentTypes);

        $reflectionFunction = new \ReflectionFunction($this->callableFunction);
        $reflectionParams = $reflectionFunction->getParameters();

        // Checking argument count.
        if (count($reflectionParams) != $argumentCount) {
            throw new CallableFunctionValidatorException(sprintf(
                'There is not sufficient argument count (required %s arguments).', $argumentCount
            ));
        }

        // Checking argument types.
        foreach ($this->argumentTypes as $k => $type) {
            if (!array_key_exists('type', $type)) {
                throw new \InvalidArgumentException('Key "type" must be defined.');
            }

            $parameter = $reflectionParams[$k];
            $class = $parameter->getClass();

            if ($type['type'] !== null) {
                if ($class === null || $type['type'] !== $class->getName()) {
                    throw new CallableFunctionValidatorException(sprintf(
                        'Argument %s must be type of "%s".', $k, $type['type']
                    ));
                }
            }

            if (array_key_exists('array', $type) && $type['array'] === true) {
                if ($class !== null) {
                    throw new CallableFunctionValidatorException(sprintf('Argument %s must be type of null.', $k));
                }

                if (!$parameter->isArray()) {
                    throw new CallableFunctionValidatorException(sprintf('Argument %s must be an array.', $k));
                }
            }
        }
    }