PHPDoc for Doctrine Collections

June 30, 2022

When working with collections in PHP entities, it’s recommended to use the Doctrine\Common\Collections\Collection interface as a type. This will allow you to use either the ArrayCollection or PersistentCollection implementation, depending on your needs. To properly document your code with PHPDoc, you can use the following syntax:

/** @var Collection<int, Article> $articles */
private Collection $articles; 

Implement