Skip to content

Add first(), next(), last() #125

@steevanb

Description

@steevanb

Search for all calls to PHP functions who modify the pointer (example: AbstractCollection::replace() whol call reset())

<?php

class Collection extends ObjectCollection
{
	public function getPointer(): CollectionPointer;
	
	public function getFirstValue(): Foo
	{
		return $this->values[array_key_first()];
	}
}

class CollectionPointer
{
	public function __construct(private readonly Collection $collection)
	{
	}
	
	public function reset(): static;
	
	public function getNextValue(): Foo;
	
	public function getFirstValue(): Foo
	{
		$this->reset();
		
		return current($this->collection->value);
	}
	
	public function getCurrentValue(): Foo;
}

$foo = new Collection();

$foo->getPointer()->getFirstValue();
$foo->getPointer()->getNextValue();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions