2
votes

In my domain model there is a property month which is an ObjectStorage for bill elements. Here is how the domain model looks:

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

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

Here is the setter:

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

Sadly phpstan shows the following error:

Parameter #1 $establishment of method VIC\Ext\Domain\Model\StorageRoom::setMonth() expects iterable&TYPO3\CMS\Extbase\Persistence\ObjectStorage,
TYPO3\CMS\Extbase\Persistence\ObjectStorage given.

Any Idea what is wrong?

1
You should add the mentioned setter to your code excerpt. Also you don't need to initialize ObjectStorage properties if you properly map them to DB fields.Mathias Brodala
Hi, they seem properly mapped in TCAVictor MGE
Foreign_table = Bill Foreign_field = StorageRoom seems right. Thanks for the tip anywayVictor MGE

1 Answers

0
votes

How to build the construct for 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);
    }