src/CartesianProduct.php
public function compute()
    {
        $product = array();

        $this->referenceSet->rewind();

        while ($this->referenceSet->valid()) {
            $product[] = $this->referenceSet->current();
            $this->referenceSet->next();
        }

        return $product;
    }
public function compute()
    {
        $product = array();

        $this->referenceSet->rewind();

        while ($this->referenceSet->valid()) {
            $product[] = $this->referenceSet->current();
            $this->referenceSet->next();
        }

        return $product;
    }
Computes the product and return the whole result.

This method is recommended only when the result is relatively small.

The recommended way to use the Cartesian Product is through its iterator interface
which is memory efficient.