我喜欢类型提示或从 PHP7 开始实际显示 getter 函数的返回值。但是对于 Doctrine / Symfony 中的一对多关系,我仍然陷入困境,并且不确定要添加到标签中的内容@var。
[...]\n\n/**\n * @var string\n * @ORM\\Column(name="name", type="string")\n */\nprivate $features;\n\n\n/**\n * What goes into var here?\n *\n * One Product has Many Features.\n * @ORM\\OneToMany(targetEntity="Feature", mappedBy="product")\n */\nprivate $features;\n\npublic function __construct()\n{\n $this->features = new ArrayCollection();\n $this->name = \'New Product Name\';\n}\n\n/**\n * @return Collection\n */\npublic function getFeatures(): Collection\n{\n return $this->features;\n}\n\n\n[...]\nRun Code Online (Sandbox Code Playgroud)\n\n目前 I\xe2\x80\x99m 使用@var Collection然后可以使用 Collection 函数。但是 \xc2\xbbproper\xc2\xab 会返回什么呢?确实如此吗Collection?或者是吗ArrayCollection?我\xe2\x80\x99m 试图使用Features[]Feature 的功能,如果我需要的话(而不是打字提示),但它\xe2\x80\x99 感觉不对。