php - Symfony 和 ReflectionProperty::getDocComment() 函数

标签 php symfony

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

有人注意到 ReflectionProperty::getDocComment()有时返回false没有任何理由吗?

我有一个 Symfony 项目并使用注释,有时注释不起作用。我发现 Symfony 使用 ReflectionProperty::getDocComment()获取注释以进行注释。

例如:

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

最佳答案

我的错。

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

关于php - Symfony 和 ReflectionProperty::getDocComment() 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16683388/

相关文章:

php - 实体依赖 Symfony2

symfony - 如何限制对除其中两个页面之外的所有页面的访问

javascript - 如何添加基于 URL 结构的动态主体类?

php - Symfony2.5,长度验证 maxMessage 属性显示带有占位符字符串而不是 "max"值的消息

php - 如何抓取包含特定单词的 youtube 视频的视频片段

php - API 使用限制

php - Symfony2 Doctrine 查询

security - 在 Symfony 2 中强制用户登录

php - 基于计时器的状态更改保存到数据库

php - SQL Select 上的循环