2011-06-14 69 views
3

我得到我的注解此错误的docblock为原则2:疑难解答“[语法错误]预计PlainValue,得到了‘)’”

Doctrine\Common\Annotations\AnnotationException: [Syntax Error] Expected PlainValue, got ')'

寻找一个答案后,我发现这个参考Stackoverflow Question 3500125这实质上是说在引号中注明所有值。

使用注释块我似乎不可能。这是我的例子,抛出错误。

/** 
* @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; 

如果我按照我在堆栈溢出这是引用了值找到答案的建议,我的代码将是这样的:

/** 
* @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; 

这是不正确的。

+0

我有很多一对多使用相同的语法,你已经有了,唯一的区别是我缩进/布局和级联。看看:https://gist.github.com/1025638 – 2011-06-14 19:21:34

+0

谢谢杰里米,我相信语法是正确的。但我仍然得到错误。它变得非常令人沮丧lol – potsed 2011-06-15 00:24:08

+0

第一个代码块看起来有效并适用于我。你使用的是什么版本的学说? – 2011-06-17 15:37:32

回答

2

这是一个愚蠢的错误,错误字符串并不是非常有用,因为它指出我在我的问题中显示的行是错误所在的行。事实是这个实体正在扩展一个父对象,父母有@Entity标签,但孩子没有,我搬它,一切工作正常。

0

对于来到这里但不是因为教义的人,我的错误是在@Routes注释中使用单引号而不是双引号。

WRONG:

/** 
* @Route('/home') 
*/ 

RIGHT

/** 
* @Route("/home") 
*/