use Doctrine\Common\Collections\ArrayCollection; $collection = new ArrayCollection([1, 2, 3]); if ($collection->isEmpty()) { echo "The collection is empty."; } else { echo "The collection is not empty."; } // Output: The collection is not empty. $emptyCollection = new ArrayCollection(); if ($emptyCollection->isEmpty()) { echo "The empty collection is indeed empty."; } else { echo "The empty collection is not empty."; } // Output: The empty collection is indeed empty.In this example, we create two instances of ArrayCollection - one with three elements and one that is empty. We then call the isEmpty() method on each collection, and print out a message depending on the result. The Doctrine\Common\Collections library is part of the Doctrine Project, a set of PHP libraries for database access and object-relational mapping.