HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/payments-gateway/vendor/doctrine/collections/docs/en/derived-collections.rst
Derived Collections
===================

You can create custom collection classes by extending the
``Doctrine\Common\Collections\ArrayCollection`` class. If the
``__construct`` semantics are different from the default ``ArrayCollection``
you can override the ``createFrom`` method:

.. code-block:: php
    final class DerivedArrayCollection extends ArrayCollection
    {
        /** @var \stdClass */
        private $foo;

        public function __construct(\stdClass $foo, array $elements = [])
        {
            $this->foo = $foo;

            parent::__construct($elements);
        }

        protected function createFrom(array $elements) : self
        {
            return new static($this->foo, $elements);
        }
    }