创建ObjectStorage实例时遇到问题

时间:2020-01-23 13:49:43

标签: typo3 extbase phpstan typo3-10.x

在我的域模型中,有一个属性month,它是ObjectStorage元素的bill。这是域模型的外观:

    /**
     * establishment
     *
     * @var ObjectStorage<Bill>
     * @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
     */
    protected ObjectStorage $month;

    public function __construct()
    {
        $this->setMonth(new ObjectStorage());
    }

这是二传手:

    /**
     * month setter
     *
     * @param ObjectStorage<Bill> $month
     * @return void
     */
    public function setMonth(ObjectStorage $month) : void
    {
        $this->month = $month;
    }

phpstan严重地显示以下错误:

参数#1 $方法VIC \ Ext \ Domain \ Model \ StorageRoom :: setMonth()的建立需要iterable&TYPO3 \ CMS \ Extbase \ Persistence \ ObjectStorage,
给出TYPO3 \ CMS \ Extbase \ Persistence \ ObjectStorage。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

如何为 phpstan 构建构造:

 /**
     * establishment
     *
     * @var ObjectStorage<Bill>
     * @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
     */
    protected $month;

    public function __construct()
    {
        /** @var ObjectStorage<Bill> $objectStorageBill */
        $objectStorageBill = new ObjectStorage();
        $this->setMonth($objectStorageBill);
    }