generated from spatie/package-skeleton-php
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from keepsuit/improved-iterable-support
Improved iterable support
- Loading branch information
Showing
6 changed files
with
96 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Keepsuit\Liquid\Tests\Stubs; | ||
|
||
/** | ||
* @implements \Iterator<int, mixed> | ||
*/ | ||
class Collection implements \Countable, \Iterator | ||
{ | ||
protected int $index = 0; | ||
|
||
protected array $data; | ||
|
||
public function __construct(?array $data = null) | ||
{ | ||
$this->data = $data ?? [ | ||
['foo' => 1, 'bar' => 2], | ||
['foo' => 2, 'bar' => 1], | ||
['foo' => 3, 'bar' => 3], | ||
]; | ||
} | ||
|
||
public function current(): mixed | ||
{ | ||
return $this->data[$this->index]; | ||
} | ||
|
||
public function next(): void | ||
{ | ||
$this->index++; | ||
} | ||
|
||
public function key(): mixed | ||
{ | ||
return $this->index; | ||
} | ||
|
||
public function valid(): bool | ||
{ | ||
return isset($this->data[$this->index]); | ||
} | ||
|
||
public function rewind(): void | ||
{ | ||
$this->index = 0; | ||
} | ||
|
||
public function count(): int | ||
{ | ||
return count($this->data); | ||
} | ||
} |