pot*_*sed 8 annotations doctrine-orm
我在Doctrine 2的注释docblock中收到此错误:
Doctrine\Common\Annotations\AnnotationException: [Syntax Error] Expected PlainValue, got ')'
在寻找答案后,我发现了这个参考Stackoverflow问题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;
Run Code Online (Sandbox Code Playgroud)
如果我按照我在堆栈溢出中找到的答案的建议来引用值,我的代码将是这样的:
/**
* @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;
Run Code Online (Sandbox Code Playgroud)
哪个不对.
Kin*_*xit 17
对于那些来到这里但不是因为学说的人来说,我的错误是在@Routes注释中使用单引号而不是双引号.
错误:
/**
* @Route('/home')
*/
Run Code Online (Sandbox Code Playgroud)
对
/**
* @Route("/home")
*/
Run Code Online (Sandbox Code Playgroud)
这是一个愚蠢的错误,错误字符串不是很有帮助,因为它指向我在问题中显示的行作为错误所在的行。事实是,该实体正在扩展父对象,父对象具有 @Entity 标记,但子对象没有,我移动了它,一切正常。
| 归档时间: |
|
| 查看次数: |
6430 次 |
| 最近记录: |