<?php declare(strict_types=1);
namespace Onion\Framework\Collection;

class CallbackCollection extends Collection
{
    /** @var callable */
    private $callback;

    public function __construct(iterable $items, callable $callback)
    {
        if (is_array($items)) {
            $items = new \ArrayIterator($items);
        }

        parent::__construct($items);
        $this->callback = $callback;
    }

    public function current()
    {
        return call_user_func($this->callback, $this, $this->key());
    }
}

<?php declare(strict_types=1);
namespace Onion\Framework\Collection;

class CallbackCollection extends Collection
{
    /** @var callable */
    private $callback;

    public function __construct(iterable $items, callable $callback)
    {
        if (is_array($items)) {
            $items = new \ArrayIterator($items);
        }

        parent::__construct($items);
        $this->callback = $callback;
    }

    public function current()
    {
        return call_user_func($this->callback, parent::current(), $this->key());
    }
}

Revert "Return self instead of parent to allow nested resolutions"
Revert "Return self instead of parent to allow nested resolutions"

This reverts commit ae2a25ad2373588c52b3a3df025f1f99e533f769.
