diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml
index eda4fa6..9113722 100644
--- a/.github/workflows/pages.yml
+++ b/.github/workflows/pages.yml
@@ -30,7 +30,7 @@ jobs:
- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
- path: 'docs/'
+ path: 'doc/'
- name: Deploy to GitHub Pages
id: deployment
diff --git a/.gitignore b/.gitignore
index 60377ba..60179c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ composer.lock
phpcs.xml
phpdoc.xml
phpstan.neon
+psalm.xml
diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml
index 8c5f41f..b40c56a 100644
--- a/phpdoc.dist.xml
+++ b/phpdoc.dist.xml
@@ -6,7 +6,7 @@
xsi:schemaLocation="https://www.phpdoc.org https://raw.githubusercontent.com/phpDocumentor/phpDocumentor/master/data/xsd/phpdoc.xsd">
PHP Basics
-
+
.phpdoc/cache
diff --git a/psalm.xml b/psalm.xml.dist
similarity index 100%
rename from psalm.xml
rename to psalm.xml.dist
diff --git a/src/DataStructures/StrictList.php b/src/DataStructures/StrictList.php
index 3244072..260010e 100644
--- a/src/DataStructures/StrictList.php
+++ b/src/DataStructures/StrictList.php
@@ -48,7 +48,7 @@ use Serializable;
* @template AllowedType of mixed
* @extends SplDoublyLinkedList
* @implements ArrayAccess
- * @implements Iterator
+ * @implements Iterator
*/
class StrictList extends SplDoublyLinkedList implements ArrayAccess, Countable, Iterator, Serializable
{
@@ -205,7 +205,7 @@ class StrictList extends SplDoublyLinkedList implements ArrayAccess, Countable,
*
* @throws InvalidArgumentException
*
- * @api
+ * @internal
*/
public function offsetSet(mixed $offset, mixed $value): void
{
diff --git a/src/DataStructures/StrictQueue.php b/src/DataStructures/StrictQueue.php
index a4758cf..1af7c65 100644
--- a/src/DataStructures/StrictQueue.php
+++ b/src/DataStructures/StrictQueue.php
@@ -43,7 +43,7 @@ use Serializable;
* @template AllowedType of mixed
* @extends StrictList
* @implements ArrayAccess
- * @implements Iterator
+ * @implements Iterator
*/
class StrictQueue extends StrictList implements ArrayAccess, Countable, Iterator, Serializable
{
diff --git a/src/DataStructures/StrictStack.php b/src/DataStructures/StrictStack.php
index afaf3b5..10a46e7 100644
--- a/src/DataStructures/StrictStack.php
+++ b/src/DataStructures/StrictStack.php
@@ -43,7 +43,7 @@ use Serializable;
* @template AllowedType of mixed
* @extends StrictList
* @implements ArrayAccess
- * @implements Iterator
+ * @implements Iterator
*/
class StrictStack extends StrictList implements ArrayAccess, Countable, Iterator, Serializable
{
diff --git a/src/InterfaceTraits/ArrayAccessTrait.php b/src/InterfaceTraits/ArrayAccessTrait.php
index 69b540a..ddd6c94 100644
--- a/src/InterfaceTraits/ArrayAccessTrait.php
+++ b/src/InterfaceTraits/ArrayAccessTrait.php
@@ -33,10 +33,8 @@ use ArrayAccess;
*
* @api
*
- * @template TKey of int|string
* @template TValue of mixed
- * @template TData of array
- * @implements ArrayAccess
+ * @implements ArrayAccess
* @phpstan-require-implements ArrayAccess
*/
trait ArrayAccessTrait
@@ -44,18 +42,18 @@ trait ArrayAccessTrait
/**
* Holds the array-accessible data.
*
- * @var TData
+ * @var array
*/
protected array $data = [];
/**
* Check if the specified offset exists.
*
- * @param TKey $offset The offset to check for
+ * @param array-key $offset The offset to check for
*
* @return bool Whether the offset exists
*
- * @api
+ * @internal
*/
public function offsetExists(mixed $offset): bool
{
@@ -65,11 +63,11 @@ trait ArrayAccessTrait
/**
* Retrieve data at the specified offset.
*
- * @param TKey $offset The offset to retrieve at
+ * @param array-key $offset The offset to retrieve
*
- * @return ?TValue The value at the offset or NULL
+ * @return ?TValue The value at the offset or NULL if invalid
*
- * @api
+ * @internal
*/
public function offsetGet(mixed $offset): mixed
{
@@ -79,12 +77,12 @@ trait ArrayAccessTrait
/**
* Assign a value to the specified offset.
*
- * @param ?TKey $offset The offset to assign to or NULL to append
+ * @param ?array-key $offset The offset to assign to or NULL to append
* @param TValue $value The value to set
*
* @return void
*
- * @api
+ * @internal
*/
public function offsetSet(mixed $offset, mixed $value): void
{
@@ -98,11 +96,11 @@ trait ArrayAccessTrait
/**
* Unset the specified offset.
*
- * @param TKey $offset The offset to unset
+ * @param array-key $offset The offset to unset
*
* @return void
*
- * @api
+ * @internal
*/
public function offsetUnset(mixed $offset): void
{
diff --git a/src/InterfaceTraits/CountableTrait.php b/src/InterfaceTraits/CountableTrait.php
index 69f10f8..58fc27e 100644
--- a/src/InterfaceTraits/CountableTrait.php
+++ b/src/InterfaceTraits/CountableTrait.php
@@ -33,10 +33,7 @@ use Countable;
*
* @api
*
- * @template TKey of int|string
* @template TValue of mixed
- * @template TData of array
- * @implements Countable
* @phpstan-require-implements Countable
*/
trait CountableTrait
@@ -44,16 +41,16 @@ trait CountableTrait
/**
* Holds the countable data.
*
- * @var TData
+ * @var array
*/
protected array $data = [];
/**
* Count the data items.
*
- * @return int The number of data items
+ * @return int<0, max> The number of data items
*
- * @api
+ * @internal
*/
public function count(): int
{
diff --git a/src/InterfaceTraits/IteratorAggregateTrait.php b/src/InterfaceTraits/IteratorAggregateTrait.php
index 83fc8d4..220c781 100644
--- a/src/InterfaceTraits/IteratorAggregateTrait.php
+++ b/src/InterfaceTraits/IteratorAggregateTrait.php
@@ -34,10 +34,8 @@ use IteratorAggregate;
*
* @api
*
- * @template TKey of int|string
* @template TValue of mixed
- * @template TData of array
- * @implements IteratorAggregate
+ * @implements IteratorAggregate
* @phpstan-require-implements IteratorAggregate
*/
trait IteratorAggregateTrait
@@ -45,16 +43,16 @@ trait IteratorAggregateTrait
/**
* Holds the iterable data.
*
- * @var TData
+ * @var array
*/
protected array $data = [];
/**
* Retrieve an external iterator.
*
- * @return ArrayIterator New array iterator for data array
+ * @return ArrayIterator New array iterator for data array
*
- * @api
+ * @internal
*/
public function getIterator(): ArrayIterator
{
diff --git a/src/InterfaceTraits/IteratorTrait.php b/src/InterfaceTraits/IteratorTrait.php
index c84a2f0..81af6f3 100644
--- a/src/InterfaceTraits/IteratorTrait.php
+++ b/src/InterfaceTraits/IteratorTrait.php
@@ -33,10 +33,8 @@ use Iterator;
*
* @api
*
- * @template TKey of int|string
* @template TValue of mixed
- * @template TData of array
- * @implements Iterator
+ * @implements Iterator
* @phpstan-require-implements Iterator
*/
trait IteratorTrait
@@ -44,28 +42,32 @@ trait IteratorTrait
/**
* Holds the iterable data.
*
- * @var TData
+ * @var array
*/
protected array $data = [];
/**
* Return the current item.
*
- * @return TValue|false The current item or FALSE if invalid
+ * @return ?TValue The current item or NULL if invalid
*
- * @api
+ * @internal
*/
public function current(): mixed
{
- return current($this->data);
+ if ($this->valid()) {
+ /** @var TValue */
+ return current($this->data);
+ }
+ return null;
}
/**
* Return the current key.
*
- * @return ?TKey The current key or NULL if invalid
+ * @return ?array-key The current key or NULL if invalid
*
- * @api
+ * @internal
*/
public function key(): mixed
{
@@ -77,31 +79,19 @@ trait IteratorTrait
*
* @return void
*
- * @api
+ * @internal
*/
public function next(): void
{
next($this->data);
}
- /**
- * Move back to previous item.
- *
- * @return void
- *
- * @api
- */
- public function prev(): void
- {
- prev($this->data);
- }
-
/**
* Rewind the iterator to the first item.
*
* @return void
*
- * @api
+ * @internal
*/
public function rewind(): void
{
@@ -113,7 +103,7 @@ trait IteratorTrait
*
* @return bool Whether the current position is valid
*
- * @api
+ * @internal
*/
public function valid(): bool
{