Zend Framework 2 表单注释在没有额外空格的情况下被忽略

Art*_*hur 5 php forms doctrine annotations zend-framework2

我花了几个小时用这个头撞墙。无论如何,我的表单字段的标签都没有出现。

最后发现,如果没有光标所在的额外空间(见图),所有注释都会被忽略。我将 ZF 2.1.1 与 Doctrine Common 2.2.3 一起使用。

难道我做错了什么?或者这是 ZF 或 Doctrine 解析器中的错误?

日食截图

作品:

   class LoginForm
   {
   /** @Annotation\Type("text")
    * @Annotation\Options({"label":"Store ID:"})
    * @Annotation\Required(true)
    * @Annotation\Filter({"name":"StringTrim"})
    * @Annotation\Validator({"name":"StringLength","options":{"min":2,"max":64}})
    */
   public $sStoreId;
   }
Run Code Online (Sandbox Code Playgroud)

失败,除非 /** 后面有一个空格:

   class LoginForm
   {
   /**
    * @Annotation\Type("text")
    * @Annotation\Options({"label":"Store ID:"})
    * @Annotation\Required(true)
    * @Annotation\Filter({"name":"StringTrim"})
    * @Annotation\Validator({"name":"StringLength","options":{"min":2,"max":64}})
    */
   public $sStoreId;
   }
Run Code Online (Sandbox Code Playgroud)

Art*_*hur 2

似乎没有解决方案,因此使用原始问题中提供的解决方法之一:

  • /**后加一个空格(容易忘记)
  • 将第一个注释或任何文本注释放在与 /** 相同的行中