Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
steevanb opened this issue Aug 24, 2023 · 0 comments
Open

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

steevanb opened this issue Aug 24, 2023 · 0 comments

Comments

@steevanb
Copy link
Owner

steevanb commented Aug 24, 2023

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant