php-resque
php-resque copied to clipboard
Throwable PHP7
Expected Behavior
PHP7 needs to catch Throwable instead Exception
Current Behavior
try-catch don't catch Throwable instead Exception
Possible Solution
refactor all try-catch
My Environment
- PHP-Resque version: latest
- PHP version: 7.1
- Operating System and version: Ubuntu 18.10
No need to refactor all try/catch. PHP Resque Exceptions just have to implement Throwable interface.
@Benoit-amo not sure that understood. for example: https://github.com/resque/php-resque/blob/fdca42bdb44197c6126d105daa4814fc5b5028ef/lib/Resque/Worker.php#L257
how this example can be refactored in other way than replacing Exception to Throwable?
Ok, I missed that. How many catch like this ?
@Benoit-amo with concrete "catch(Exception $e)" it seems only 1 occurence.
but exist some child-exceptions which has extended from Exception OR type-hinted parameters in methods: https://github.com/resque/php-resque/blob/fdca42bdb44197c6126d105daa4814fc5b5028ef/lib/Resque/Failure.php#L25 i am not sure which one should be updated to Throwable and which one not.
There are a lot of PHP 7 updates that haven't been done yet. This one is relatively minor, as \Exception extends \Throwable anyway, so only \Errors will be uncaught, which is consistent with PHP 5 behavior. (AIUI, it's illegal to extend or even implement the \Throwable interface directly anyway, so only type hints should be updated even when we version bump to add this change.)
In other words, this will be a BC break, and will need several other PHP 7 changes in place before it makes any sense to do. So this will be an item on the PHP 7 checklist.