我使用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
。