首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Symfony和ReflectionProperty::getDocComment()函数

Symfony和ReflectionProperty::getDocComment()函数
EN

Stack Overflow用户
提问于 2013-05-22 12:18:40
回答 1查看 350关注 0票数 1

我使用的是PHP 5.4.15,MS windows Pro 64位,apache 2.4和Symfony 2.2。

有没有人注意到ReflectionProperty::getDocComment()有时会无缘无故地返回false

我有一个Symfony项目,使用注解,有时注解就是不起作用。我还发现Symfony使用ReflectionProperty::getDocComment()来获取注释,用于注释目的。

例如:

代码语言:javascript
运行
复制
/**
 * 
 * @ORM\Entity
 * @ORM\Table(name="orders")
 * 
 */
class Order
{

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /** @ORM\OneToOne(targetEntity="JMS\Payment\CoreBundle\Entity\PaymentInstruction") */
    protected $paymentInstruction;

    /** @ORM\Column(type="decimal", precision = 2) */
    protected $amount;
}

ReflectionProperty::getDocComment()处理$amount字段时,它返回的不是该字段的注释,而是false

如果我将该字段移到类的顶部,则不会处理$paymentInstruction

让注解生效的唯一方法是以特定的顺序(排列)移动类字段,并且ReflectionProperty::getDocComment()不会返回false

EN

回答 1

Stack Overflow用户

发布于 2013-05-22 13:04:32

是我的错。

PHP文档注释应该以/**开头,但在我的类中,有时我使用/*,这就是getDocComment()返回false的原因。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16683388

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档