I think in all programming languages Exception class is instance of Throwable interface.
Take a look at following code which shows Exception is not instance of Throwable in php.
try {
throw new InvalidArgumentException("error message");
} catch (InvalidArgumentException $e) {
if ($e instanceof Exception) {
echo '$e is exception'; // this line gets executed
}
if ($e instanceof Throwable) {
echo '$e is throwable'; // but this one never
}
}
It makes problem with chaining exceptions where Exception class constructor accepts Throwable in it's last argument.
php version: 5.6.23
Any solution?
Throwable is the base interface for any object that can be thrown via a throw statement in PHP 7, including Error and Exception. And your code produces: $e is exception $e is throwable if you have PHP version >= 7
But you have PHP version 5.6.23, so Throwable interface is not available for this version.