use Doctrine\Common\Collections\ArrayCollection; $collection = new ArrayCollection(['Element 1', 'Element 2', 'Element 3']); $collection->clear();
use Doctrine\Common\Collections\Criteria; $criteria = Criteria::create() ->where(Criteria::expr()->eq('status', 1)); $collection = $repository->matching($criteria); $collection->clear();This code uses the `matching()` method to return all objects from the repository that match the criteria. Then the `clear()` method is used to remove all elements from the collection. The `clear()` method belongs to the `Doctrine\Common\Collections` package library, which provides a collection interface for PHP.