Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
 */
private $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.

like image 248
potsed Avatar asked Jun 14 '11 01:06

potsed


2 Answers

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")
*/
like image 69
Kinjal Dixit Avatar answered Nov 14 '22 17:11

Kinjal Dixit


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.

like image 40
potsed Avatar answered Nov 14 '22 17:11

potsed