mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
AnnotationReader unable to parse annotations if the comment field contains an accented character (é, è, ...) #7032
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jkazal on GitHub (Aug 31, 2022).
Bug Report
Summary
Sometimes
AnnotationReaderfails to parse the annotations of a given class, if that class's entity definition contains PHPDoc comments that include accented characters.I am filing this as a bug report rather than an upgrade issue because I don't know if it did the same thing before the upgrade as the bug scenario wasn't applicable previously.
Current behavior
After upgrading my VM to PHP 7.4, Doctrine returned errors like this for every entity:
However both classes had the correct annotations, but debugging showed me that Doctrine's
AnnotationReaderfailed to get the annotations from myMyEntityclass.After debugging for some time I finally found the source of the problem:
AnnotationReaderwas unable to read the annotationsEntityandTablebecause of the accented character inhérite. By changing it to a normale, I can get the annotations just fine.I imagine this is unintended.
How to reproduce
See above
For the sake of information, my entity class files are encoded in
windows-1252.Expected behavior
I think having PHPDoc comments like
@authorthat contain accented characters should not impact the wayAnnotationReaderparses a class's annotation.@greg0ire commented on GitHub (Aug 31, 2022):
Can you please post a stack trace?
@jkazal commented on GitHub (Aug 31, 2022):
I'm not using Symfony so I can't give you a Symfony stack trace. I can give you the Fatal Error trace:
@jkazal commented on GitHub (Aug 31, 2022):
In addition, it seems the issue is fixed by switching the class file encoding to UTF-8 for the affected Entities.
@derrabus commented on GitHub (Aug 31, 2022):
Well, what encoding did you use previously? That would be an important piece of information to track down the issue. That being said, I'm not really keen on fixing the Doctrine Annotations library for non-UTF-8 encodings.
@jkazal commented on GitHub (Aug 31, 2022):
As mentioned in the OP:
That being said, if UTF8 is the only encoding supported by Doctrine Annotations that's also fine, however I couldn't find any info regarding that. Feel free to close the issue if that's the case
@derrabus commented on GitHub (Aug 31, 2022):
Oh sorry, I missed that. 🙈
If converting those files to UTF-8 works for you, I'd be in favor of closing the issue. Doctrine Annotations don't have a bright future, now that PHP has native attributes. Fixing this issue is probably not worth the effort.