-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Anonymous class reference in trigger_error / thrown Exception #13097
Comments
Anonymous classes contain a non printable |
I guess a workaround would be: preg_replace('/[\x00]/', '',$class::class); |
I quickly had a look yesterday, but we're relying on some API that doesn't support |
This seems to work: https://gist.github.com/nielsdos/79419e56941ae80062e1b382c7e275f9
|
The fix looks correct to me, although tbh I'm not sure it's worthwhile. For |
Idk either, I don't like the complication.
TIL, thx
Hm indeed, confusing function and confusing naming. |
I would like to see this fixed as well, it's definitely weird and buggy to see error messages cut-off. From the perspective of a PHP user \0 isn't really special. |
I don't object to fixing this. @nielsdos Feel free to create a PR. |
* PHP-8.2: Fix GH-13097: Anonymous class reference in trigger_error / thrown Exception
* PHP-8.3: Fix GH-13097: Anonymous class reference in trigger_error / thrown Exception
Description
The following code is a bug since the introduction of anonymous classes in PHP 7.0:
https://3v4l.org/0OTZ9#v7.0.0 // for reference
https://3v4l.org/0OTZ9#v8.3.1
Note: it doesn't matter if get_class or $anonymous::class is used. As soon as it is an anonymous class name, it fails.
It also fails when throwing an Exception:
Resulted in this output:
But I expected this output instead:
PHP Version
PHP 8.3.1
Operating System
No response
The text was updated successfully, but these errors were encountered: