From 41ac00e3e0d19c34b808f920ce6c2671d0e4f87a Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 9 Nov 2023 13:12:34 +0000 Subject: [PATCH] Cleanups in XArray. --- VERSION | 2 +- src/{Collections => }/ArrayIterator.php | 31 +++++++++++++++++++++++-- src/Collections/IArrayable.php | 10 -------- src/XArray.php | 6 +---- src/XNumber.php | 3 ++- 5 files changed, 33 insertions(+), 19 deletions(-) rename src/{Collections => }/ArrayIterator.php (51%) delete mode 100644 src/Collections/IArrayable.php diff --git a/VERSION b/VERSION index 3335ccb..5a11be7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2311.91259 +0.2311.91312 diff --git a/src/Collections/ArrayIterator.php b/src/ArrayIterator.php similarity index 51% rename from src/Collections/ArrayIterator.php rename to src/ArrayIterator.php index dc15d58..3416d68 100644 --- a/src/Collections/ArrayIterator.php +++ b/src/ArrayIterator.php @@ -1,36 +1,63 @@ array = $array; } + /** + * Returns the current element. + * + * @return mixed Can return any type. + */ public function current(): mixed { return current($this->array); } + /** + * Returns the key of the current element. + * + * @return mixed Returns scalar on success, or null on failure. + */ public function key(): mixed { return key($this->array); } + /** + * Moves forward to next element. + */ public function next(): void { $this->wasValid = next($this->array) !== false; } + /** + * Rewind the Iterator to the first element. + */ public function rewind(): void { $this->wasValid = reset($this->array) !== false; } + /** + * Checks if current position is valid. + * + * @return bool Returns true on success or false on failure. + */ public function valid(): bool { return $this->wasValid; } diff --git a/src/Collections/IArrayable.php b/src/Collections/IArrayable.php deleted file mode 100644 index 1a9aa87..0000000 --- a/src/Collections/IArrayable.php +++ /dev/null @@ -1,10 +0,0 @@ -toArray(); $items = []; diff --git a/src/XNumber.php b/src/XNumber.php index 3ed7605..a8df0f7 100644 --- a/src/XNumber.php +++ b/src/XNumber.php @@ -1,11 +1,12 @@