[php-src] Issue #8033: Unexpected stop of the script after an exception breaking the expected workflow
| From: | iluuu1994 | Date: | Fri, 04 Feb 2022 11:17:55 +0000 |
| Subject: | [php-src] Issue #8033: Unexpected stop of the script after an exception breaking the expected workflow | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-239479@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8033
Comment Author: iluuu1994
Hi @josepsanzcamp
From the documentation:
https://www.php.net/manual/en/function.set-exception-handler.php
> Sets the default exception handler if an exception is not caught within a try/catch block.
> Execution will stop after the callback is called.
So this is indeed the correct behavior. What changed in PHP 8 is just that this was previously a
warning:
https://3v4l.org/vgMvd
```php
array_combine([1], [1, 2]);
```
> PHP <8.0
> Warning: array_combine(): Both parameters should have an equal number of elements
> PHP >=8.0
> Uncaught ValueError: array_combine(): Argument #1 ($keys) and argument #2 ($values) must have
> the same number of elements
Errors are different than exceptions in that they don't stop execution after an error has been
triggered and caught by an error handler.
As for the feature request, not stopping after the exception would be an incredibly dangerous
change. So unfortunately there's no simple solution other than to fix your code. Sorry.