我得到我的註解此錯誤的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;
這是不正確的。
我有很多一對多使用相同的語法,你已經有了,唯一的區別是我縮進/佈局和級聯。看看:https://gist.github.com/1025638 – 2011-06-14 19:21:34
謝謝傑里米,我相信語法是正確的。但我仍然得到錯誤。它變得非常令人沮喪lol – potsed 2011-06-15 00:24:08
第一個代碼塊看起來有效並適用於我。你使用的是什麼版本的學說? – 2011-06-17 15:37:32