Get the hint for an exception handler.

@param callable $callback

@return string
@throws \ReflectionException
16577
protected function handlerHint(callable $callback): string
    {
        $reflection = new ReflectionFunction($callback);

        $exception = $reflection->getParameters()[0];

        return $exception->getClass()->getName();
    }
1010120
protected function handlesException(Closure $handler, $exception)
	{
		$reflection = new ReflectionFunction($handler);

		return $reflection->getNumberOfParameters() == 0 || $this->hints($reflection, $exception);
	}
1095739
private function callOnException(\Exception $exception)
    {
        if (is_null($this->onException)) {
            throw  $exception;
        }

        $closure = $this->onException;

        $message = $closure($this, $exception);

        return $message;
    }
1362014
protected function getParamMap($callback)
    {
        if (is_null($callback)) {
            return array(array('*', true));
        }
        if (is_array($callback)) {
            $ref = new ReflectionMethod($callback[0], $callback[1]);
        } else {
            $ref = new ReflectionFunction($callback);
        }

        $out = array();
        foreach ($ref->getParameters() as $param) {
            if (($class = $param->getClass()) !== null && $class->name === 'Dwoo\Core') {
                continue;
            }
            if (($class = $param->getClass()) !== null && $class->name === 'Dwoo\Compiler') {
                continue;
            }
            if ($param->getName() === 'rest' && $param->isArray() === true) {
                $out[] = array('*', $param->isOptional(), null);
                continue;
            }
            $out[] = array(
                $param->getName(),
                $param->isOptional(),
                $param->isOptional() ? $param->getDefaultValue() : null
            );
        }

        return $out;
    }
584665
public function exceptionHandler($exception) {
		try {
			// load errorhandler
			$debug = Factory::load('Debug');
			$debug->errorhandler($exception);
		} catch (\Exception $e) {
			echo "<pre>$exception</pre>\n\n";

			// useful if the \Exception handler itself contains errors
			echo "<pre>The Debug class threw an exception:\n$e</pre>";
		}
	}
521727
public function exportCallable($callback): string
    {
        $wrappedCallback = null;

        while ($callback instanceof WrappedInvocable) {
            $wrappedCallback = $callback;
            $callback = $callback->callback();
        }

        $label = '';

        if ($wrappedCallback) {
            if ($wrappedCallback->isAnonymous()) {
                return $this->export($wrappedCallback);
            }

            $label = $wrappedCallback->label();

            if ('' !== $label) {
                $label = '[' . $label . ']';
            }
        }

        if ($callback instanceof Closure) {
            return $this->export($callback) . $label;
        }

        $reflector = $this->invocableInspector->callbackReflector($callback);

        if (!$reflector instanceof ReflectionMethod) {
            return $reflector->getName() . $label;
        }

        $class = $reflector->getDeclaringClass();
        $name = $reflector->getName();

        if ($class->implementsInterface(Mock::class)) {
            if (
                ($parentClass = $class->getParentClass()) &&
                $parentClass->hasMethod($name)
            ) {
                $class = $parentClass;
            } else {
                try {
                    $prototype = $reflector->getPrototype();
                    $class = $prototype->getDeclaringClass();
                } catch (ReflectionException $e) {
                    // ignore
                }
            }
        }

        $atoms = explode('\\', $class->getName());
        $rendered = array_pop($atoms);

        if ($wrappedCallback instanceof WrappedMethod) {
            $name = $wrappedCallback->name();
            $handle = $wrappedCallback->handle();

            if ($handle instanceof InstanceHandle) {
                $label = $handle->label();

                if ('' !== $label) {
                    $rendered .= '[' . $label . ']';
                }
            }
        }

        if ($reflector->isStatic()) {
            $callOperator = '::';
        } else {
            $callOperator = '->';
        }

        return $rendered . $callOperator . $name;
    }
1143358
protected function getId(callable $callback): string
    {
        if (is_array($callback)) {
            if (isset($callback[0]) && is_object($callback[0])) {
                $callback[0] = spl_object_hash($callback[0]);
            }

            return $callback[0].'::'.$callback[1];
        }

        if ($callback instanceof Closure) {
            return spl_object_hash($callback);
        }

        return $callback;
    }
1205497
protected function getVerifyCredentialsCallback()
    {
        if (is_null($this->callback) || !is_callable($this->callback)) {
            throw new Exception\ServerErrorException('Null or non-callable callback set on Password grant');
        }

        return $this->callback;
    }
596315
protected function executeCallback($callback, $args)
    {
        if (is_string($callback)) {
            return $this->callStringCallback($callback, $args);
        } elseif ($callback instanceof Closure) {
            return call_user_func_array($callback, $args);
        }

        return '';
    }
671832
public function find(callable $callback)
    {
        $array = $this->getArrayCopy();
        foreach ($array as $key => $value) {
            if ($callback($value, $key, $array) === true) {
                return $value;
            }
        }
    }
77640
public function createFromCallback($callback): SpyVerifier
    {
        return new SpyVerifier(
            $this->spyFactory->create($callback),
            $this->matcherFactory,
            $this->matcherVerifier,
            $this->generatorVerifierFactory,
            $this->iterableVerifierFactory,
            $this->callVerifierFactory,
            $this->assertionRecorder,
            $this->assertionRenderer
        );
    }
86744
protected function checkAndReturnCallable($callback)
    {
        if (is_string($callback)) {
            return function ($app) use ($callback) {
                return $app($callback);
            };
        }

        if (!is_callable($callback)) {
            $type = is_object($callback) ? get_class($callback) : gettype($callback);
            throw new InvalidArgumentException("Passed argument of type $type is not callable");
        }

        return $callback;
    }
1339336
public function setExceptionHandler(callable $handler = null)
    {
        $prev = $this->exceptionHandler;
        $this->exceptionHandler = $handler;

        return $prev;
    }
1312782
public static function createFromCallable(callable $callback): \ReflectionFunctionAbstract
    {
        if (\is_array($callback)) {
            return new \ReflectionMethod($callback[0], $callback[1]);
        }

        if (\is_object($callback)) {
            return new \ReflectionMethod($callback, '__invoke');
        }

        return new \eflectionFunction($callback);
    }
580643
public function setCallback($callback)
    {
        if (!$callback instanceof Closure) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Invalid parameter for callback: must be %s',
                Closure::class
            ));
        }

        return parent::setCallback($callback);
    }
954172
public function setJsonCallbackWrap($callback)
    {

        if (empty($callback)) {
            $this->jsonCallbackWrap = false;
            return;
        }

        if (!is_string($callback)) {
            throw new \Exception('JSON callback wrap should be a string or false.');
        }

        $this->jsonCallbackWrap = $callback;
    }
251825
public function createFromCallback($callback): StubVerifier
    {
        $stub = $this->stubFactory->create($callback);

        $verifier = new StubVerifier(
            $stub,
            $this->spyFactory->create($stub),
            $this->matcherFactory,
            $this->matcherVerifier,
            $this->generatorVerifierFactory,
            $this->iterableVerifierFactory,
            $this->callVerifierFactory,
            $this->assertionRecorder,
            $this->assertionRenderer,
            $this->generatorAnswerBuilderFactory
        );
        $verifier->setSelf($verifier);

        return $verifier;
    }