I am trying to create a function that when called is passed a callable and an exception "type", either as a ::class string or something like that. The idea would be that the function would call the callback inside of a try/catch block.
Sample Function:
public static function try(callable $callback, string $exceptionClass) : object | null {
try {
...
$callback();
...
catch($exceptionClass $e) {
...
}
}
I found this answer. But I'm not sure how to get the type.