common icon indicating copy to clipboard operation
common copied to clipboard

Escape " in Annotation

Open Baachi opened this issue 14 years ago • 7 comments

Is it possible to protect a quotation mark, for example, with a ""?

Like this:

<?php
/**
 * @Unique(fields={"name"}, message="The name \"{{ value }}\" is already in use!")
 */
class User {}

Baachi avatar May 14 '12 14:05 Baachi

Hi @Baachi

I think so :)

Could you add this issue on jira please ? http://www.doctrine-project.org/jira/

Thanks..

FabioBatSilva avatar May 14 '12 14:05 FabioBatSilva

To escape a quotation mark, you can double it.

stof avatar May 14 '12 15:05 stof

Thanks @stof .

But i think the backslash would be better, or what do you think?

Baachi avatar May 14 '12 16:05 Baachi

The current escaping format is a double ". Won't change in 2.x

Ocramius avatar Dec 23 '13 07:12 Ocramius

how do I get rid on the backslashes the double " adds to my example?

wraycode avatar Aug 22 '17 19:08 wraycode

I want to know if I can get ideas in these two areas: 1: Is it possible to do this by overriding the AnnotationReader class, but I'm not sure what his specific implementation idea is, and there are many details to be aware of. 2: php syntax support, such as string type can be achieved using a delimiter such as <<< EOF.

xiaozixiangfeng avatar Jun 06 '18 15:06 xiaozixiangfeng

Ad 1: For the upcoming Annotations 2.0 it's planned to switch to \ as an escape character. This can't to be done in 1.x. Ad 2: If you have some proposals, I'd suggest to open an issue over on doctrine/annotations repo instead of discussing it here in a old, closed issue.

Majkl578 avatar Jun 06 '18 15:06 Majkl578