Troubleshooting "[Syntax Error] Expected PlainValue, got ')'"
I am getting this error in my annotations docblock for Doctrine 2:
Doctrine\Common\Annotations\AnnotationException: [Syntax Error] Expected PlainValue, got ')'
After looking for an answer I found this reference Stackoverflow Question 3500125 which in essence says to put quotes around all values in annotations.
With the annotation block I have this does not seem possible. here is my example that is throwing the error.
/**
* @var tags
*
* @ManyToMany(targetEntity="namespace\to\tag")
* @JoinTable(name="content_tag",
* joinColumns={
* @JoinColumn(name="content_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @JoinColumn(name="tag_id", referencedColumnName="id")
* }
* ) // This is the line indicated by the error
*/
priva开发者_运维知识库te $tags;
If I follow the advice of the answer I found in stack overflow which is to quote out the values, my code will be like this:
/**
* @var tags
*
* @ManyToMany(targetEntity="namespace\to\tag")
* @JoinTable(name="content_tag",
* joinColumns="{
* @JoinColumn(name="content_id", referencedColumnName="id")
* }",
* inverseJoinColumns="{
* @JoinColumn(name="tag_id", referencedColumnName="id")
* }" // Note the extra quotation marks
* )
*/
private $tags;
Which is not right at all.
For people who have come here but not because of doctrine, my mistake was using single quotes instead of double quotes in the @Routes
annotation.
WRONG:
/**
* @Route('/home')
*/
RIGHT
/**
* @Route("/home")
*/
It was a silly mistake, the error string was not very helpful as it pointed to the line i showed in my question as the line that the error was on. The fact was that this entity was extending a parent object, the parent had the @Entity tag but the child did not, i moved it and everything works fine.
I Just had the same kind of error by using an assert for an entity :
* @Assert\Email(
* message = "The email '{{ value }}' is not a valid email.",
* mode = 'strict',
* normalizer = 'trim'
* )
Turning it into
* @Assert\Email(
* message = "The email '{{ value }}' is not a valid email.",
* mode = "strict",
* normalizer = "trim"
* )
Fixed it :)
精彩评论