-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it clearer that Exceptions cannot be cloned #3418
Comments
Hi @SigmaFlame. See php/php-src#6892, the |
There already is a note about not being able to clone exceptions: https://www.php.net/manual/en/language.exceptions.extending.php |
@Girgias Indeed. I think this is referencing: https://www.php.net/manual/en/exception.clone.php
Without more context, this sounds like exceptions may now be cloneable. But they are not, even though they allow defining the |
I think removing the changelog is probably sensible, and wrapping one of the "Exceptions are not clonable" in a warning tag so that it stands out. |
But why exceptions could not be cloned in the first place? |
Honestly, I have no idea what the rationale is for making exceptions unclonable. But it's been that way forever. |
Description
Hello,
While reading the PHP documentation, I have read that the method Exception::__clone() is no longer final since PHP 8.1.
But, trying to extend the class Exception and making its own « public function __clone() » does not work and still produce an error.
« Trying to clone an uncloneable object of class ExtendedException »
What is the purpose of removing the final attribute of this method if we still can't clone an exception?
I would like to make the exception clonable in order to update the file and line where the exception has occurred.
Thanks you in advance.
PHP Version
8.3.7
Operating System
No response
The text was updated successfully, but these errors were encountered: