The common interface of all type-sensitive, SPL-based datastructures.
-
-
This extends all methods of the common interface of the Standard PHP Library
-Doubly Linked List Datastructures
-by type-checking to only allow specified data types on the list.
This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/.
This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/.
This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/.
This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/.
This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/.
This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/.
-
-
-
-
-
-
-
-
-
-
-
diff --git a/doc/files/src/DataStructures/Collection.php.txt b/doc/files/src/DataStructures/Collection.php.txt
deleted file mode 100644
index 7d95fd9..0000000
--- a/doc/files/src/DataStructures/Collection.php.txt
+++ /dev/null
@@ -1,195 +0,0 @@
-
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-declare(strict_types=1);
-
-namespace OCC\Basics\DataStructures;
-
-use ArrayAccess;
-use Countable;
-use IteratorAggregate;
-use OCC\Basics\InterfaceTraits\ArrayAccessTrait;
-use OCC\Basics\InterfaceTraits\CountableTrait;
-use OCC\Basics\InterfaceTraits\IteratorAggregateTrait;
-
-/**
- * A generic collection of items.
- *
- * @author Sebastian Meyer
- * @package Basics\DataStructures
- *
- * @api
- *
- * @template Item of mixed
- * @implements ArrayAccess
- * @implements IteratorAggregate
- */
-class Collection implements ArrayAccess, Countable, IteratorAggregate
-{
- /** @use ArrayAccessTrait */
- use ArrayAccessTrait;
- /** @use CountableTrait */
- use CountableTrait;
- /** @use IteratorAggregateTrait */
- use IteratorAggregateTrait;
-
- /**
- * Add an item to the collection.
- *
- * @param Item $item The new item
- *
- * @return void
- *
- * @api
- */
- public function add(mixed $item): void
- {
- $this->data[] = $item;
- }
-
- /**
- * Clear the collection of any items.
- *
- * @return void
- *
- * @api
- */
- public function clear(): void
- {
- $this->data = [];
- }
-
- /**
- * Get a new collection with the same set of items.
- *
- * @return Collection The new collection with the same items
- *
- * @api
- */
- public function copy(): Collection
- {
- return new Collection($this->data);
- }
-
- /**
- * Get the item at the specified index.
- *
- * @param array-key $key The item's index
- *
- * @return ?Item The item or NULL if key is invalid
- *
- * @api
- */
- public function get(int|string $key): mixed
- {
- return $this->data[$key] ?? null;
- }
-
- /**
- * Check if collection is empty.
- *
- * @return bool Whether the collection contains any items
- *
- * @api
- */
- public function isEmpty(): bool
- {
- return $this->count() === 0;
- }
-
- /**
- * Remove an item from the collection.
- *
- * @param array-key $key The item's key
- *
- * @return void
- *
- * @api
- */
- public function remove(int|string $key): void
- {
- unset($this->data[$key]);
- }
-
- /**
- * Set the item at the specified index.
- *
- * @param array-key $key The new item's index
- * @param Item $item The new item
- *
- * @return void
- *
- * @api
- */
- public function set(int|string $key, mixed $item): void
- {
- $this->data[$key] = $item;
- }
-
- /**
- * Return array representation of collection.
- *
- * @return array Array of collection items
- *
- * @api
- */
- public function toArray(): array
- {
- return $this->data;
- }
-
- /**
- * Create a collection of items.
- *
- * @param array $items Initial set of items
- *
- * @return void
- */
- public function __construct(array $items = [])
- {
- $this->data = $items;
- }
-
- /**
- * Magic method to read collection items as properties.
- *
- * @param array-key $key The item's index
- *
- * @return ?Item The item or NULL if key is invalid
- */
- public function __get(int|string $key): mixed
- {
- return $this->get($key);
- }
-
- /**
- * Magic method to write collection items as properties.
- *
- * @param array-key $key The new item's index
- * @param Item $item The new item
- *
- * @return void
- */
- public function __set(int|string $key, mixed $item): void
- {
- $this->set($key, $item);
- }
-}
diff --git a/doc/files/src/DataStructures/StrictArray.php.txt b/doc/files/src/DataStructures/StrictArray.php.txt
index afb74da..bd590ea 100644
--- a/doc/files/src/DataStructures/StrictArray.php.txt
+++ b/doc/files/src/DataStructures/StrictArray.php.txt
@@ -24,7 +24,9 @@ declare(strict_types=1);
namespace OCC\Basics\DataStructures;
use Iterator;
+use OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException;
use OCC\Basics\Interfaces\IteratorTrait;
+use RuntimeException;
/**
* A type-sensitive, traversable array.
@@ -49,4 +51,130 @@ class StrictArray extends StrictCollection implements Iterator
{
/** @use IteratorTrait */
use IteratorTrait;
+
+ /**
+ * Peek at the first item of the array.
+ *
+ * @return AllowedType The first item of the array
+ *
+ * @throws RuntimeException if the array is empty
+ *
+ * @api
+ */
+ public function bottom(): mixed
+ {
+ $key = array_key_first($this->_data);
+ if (is_null($key)) {
+ throw new RuntimeException(
+ 'Cannot return bottom item: array is empty.'
+ );
+ }
+ return $this->_data[$key];
+ }
+
+ /**
+ * Pop the item from the end of the array.
+ *
+ * @return AllowedType The last item of the array
+ *
+ * @throws RuntimeException if the array is empty
+ *
+ * @api
+ */
+ public function pop(): mixed
+ {
+ if ($this->count() === 0) {
+ throw new RuntimeException(
+ 'Cannot return last item: array is empty.'
+ );
+ }
+ return array_pop($this->_data);
+ }
+
+ /**
+ * Push an item at the end of the array.
+ *
+ * @param AllowedType $value The item to push
+ *
+ * @return void
+ *
+ * @throws InvalidDataTypeException if `$value` is not of allowed type
+ *
+ * @api
+ */
+ public function push(mixed $value): void
+ {
+ if (!$this->hasAllowedType($value)) {
+ throw new InvalidDataTypeException(
+ sprintf(
+ 'Parameter 1 must be an allowed type, %s given.',
+ get_debug_type($value)
+ )
+ );
+ }
+ array_push($this->_data, $value);
+ }
+
+ /**
+ * Shift the item from the beginning of the array.
+ *
+ * @return AllowedType The first item of the array
+ *
+ * @throws RuntimeException if the array is empty
+ *
+ * @api
+ */
+ public function shift(): mixed
+ {
+ if ($this->count() === 0) {
+ throw new RuntimeException(
+ 'Cannot return first item: array is empty.'
+ );
+ }
+ return array_shift($this->_data);
+ }
+
+ /**
+ * Peek at the last item of the array.
+ *
+ * @return AllowedType The last item of the array
+ *
+ * @throws RuntimeException if the array is empty
+ *
+ * @api
+ */
+ public function top(): mixed
+ {
+ $key = array_key_last($this->_data);
+ if (is_null($key)) {
+ throw new RuntimeException(
+ 'Cannot return top item: array is empty.'
+ );
+ }
+ return $this->_data[$key];
+ }
+
+ /**
+ * Prepend the array with an item.
+ *
+ * @param AllowedType $value The item to unshift
+ *
+ * @return void
+ *
+ * @throws InvalidDataTypeException if `$value` is not of allowed type
+ *
+ * @api
+ */
+ public function unshift(mixed $value): void
+ {
+ if (!$this->hasAllowedType($value)) {
+ throw new InvalidDataTypeException(
+ sprintf(
+ 'Parameter 1 must be an allowed type, %s given.',
+ get_debug_type($value)
+ )
+ );
+ }
+ array_unshift($this->_data, $value);
+ }
}
diff --git a/doc/files/src/DataStructures/StrictList.php.txt b/doc/files/src/DataStructures/StrictList.php.txt
index be8f407..737b92f 100644
--- a/doc/files/src/DataStructures/StrictList.php.txt
+++ b/doc/files/src/DataStructures/StrictList.php.txt
@@ -23,7 +23,7 @@ declare(strict_types=1);
namespace OCC\Basics\DataStructures;
-use OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait;
+use OCC\Basics\DataStructures\Traits\StrictSplDoublyLinkedListTrait;
use SplDoublyLinkedList;
/**
@@ -43,6 +43,6 @@ use SplDoublyLinkedList;
*/
class StrictList extends SplDoublyLinkedList
{
- /** @use StrictSplDatastructureTrait */
- use StrictSplDatastructureTrait;
+ /** @use StrictSplDoublyLinkedListTrait */
+ use StrictSplDoublyLinkedListTrait;
}
diff --git a/doc/files/src/DataStructures/StrictQueue.php.txt b/doc/files/src/DataStructures/StrictQueue.php.txt
index 266fa7c..caa9cb4 100644
--- a/doc/files/src/DataStructures/StrictQueue.php.txt
+++ b/doc/files/src/DataStructures/StrictQueue.php.txt
@@ -24,7 +24,8 @@ declare(strict_types=1);
namespace OCC\Basics\DataStructures;
use OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException;
-use OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait;
+use OCC\Basics\DataStructures\Traits\StrictSplDoublyLinkedListTrait;
+use RuntimeException;
use SplQueue;
/**
@@ -44,8 +45,22 @@ use SplQueue;
*/
class StrictQueue extends SplQueue
{
- /** @use StrictSplDatastructureTrait */
- use StrictSplDatastructureTrait;
+ /** @use StrictSplDoublyLinkedListTrait */
+ use StrictSplDoublyLinkedListTrait;
+
+ /**
+ * Dequeue an item from the queue.
+ *
+ * @return AllowedType The dequeued item
+ *
+ * @throws RuntimeException if the queue is empty
+ *
+ * @api
+ */
+ public function dequeue(): mixed
+ {
+ return $this->shift();
+ }
/**
* Add an item to the queue.
diff --git a/doc/files/src/DataStructures/StrictSplDatastructureTrait.php.txt b/doc/files/src/DataStructures/StrictSplDatastructureTrait.php.txt
deleted file mode 100644
index 8608abc..0000000
--- a/doc/files/src/DataStructures/StrictSplDatastructureTrait.php.txt
+++ /dev/null
@@ -1,420 +0,0 @@
-
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-declare(strict_types=1);
-
-namespace OCC\Basics\DataStructures;
-
-use InvalidArgumentException;
-use OCC\Basics\Traits\TypeChecker;
-use OutOfRangeException;
-
-use function get_debug_type;
-use function iterator_to_array;
-use function serialize;
-use function sprintf;
-use function unserialize;
-
-/**
- * The common interface of all type-sensitive, SPL-based datastructures.
- *
- * This extends all methods of the common interface of the Standard PHP Library
- * [Doubly Linked List Datastructures](https://www.php.net/spl.datastructures)
- * by type-checking to only allow specified data types on the list.
- *
- * @author Sebastian Meyer
- * @package Basics\DataStructures
- *
- * @template AllowedType of mixed
- */
-trait StrictSplDatastructureTrait
-{
- use TypeChecker {
- setAllowedTypes as protected;
- }
-
- /**
- * Add/insert a new item at the specified offset.
- *
- * @param int $offset The offset where the new item is to be inserted
- * @param AllowedType $value The new item for the offset
- *
- * @return void
- *
- * @throws InvalidArgumentException if `$value` is not of allowed type
- * @throws OutOfRangeException when `$offset` is out of bounds
- *
- * @api
- */
- public function add(int $offset, mixed $value): void
- {
- $this->offsetSet($offset, $value);
- }
-
- /**
- * Append items at the end of the list.
- *
- * @param AllowedType ...$values One or more items to append
- *
- * @return void
- *
- * @throws InvalidArgumentException if any `$values` is not of allowed type
- *
- * @api
- */
- public function append(mixed ...$values): void
- {
- /** @var array $values */
- foreach ($values as $count => $value) {
- if (!$this->hasAllowedType($value)) {
- throw new InvalidArgumentException(
- sprintf(
- 'Parameter %d must be an allowed type, %s given.',
- $count + 1,
- get_debug_type($value)
- )
- );
- }
- }
- foreach ($values as $value) {
- parent::push($value);
- }
- }
-
- /**
- * Clear the list of any items.
- *
- * @return void
- *
- * @api
- */
- public function clear(): void
- {
- while (!$this->isEmpty()) {
- $this->pop();
- }
- $this->rewind();
- }
-
- /**
- * Get the item at the specified index.
- *
- * @param int $offset The item's index
- *
- * @return AllowedType The item
- *
- * @throws OutOfRangeException when `$offset` is out of bounds
- *
- * @api
- */
- public function get(int $offset): mixed
- {
- return $this->offsetGet($offset);
- }
-
- /**
- * Check if this can be considered a list.
- *
- * @return true Always TRUE (this exists only for compatibility reasons)
- *
- * @api
- */
- public function isList(): bool
- {
- return true;
- }
-
- /**
- * Set the item at the specified offset.
- *
- * @param ?int $offset The offset being set or NULL to append
- * @param AllowedType $value The new item for the offset
- *
- * @return void
- *
- * @throws InvalidArgumentException if `$value` is not of allowed type
- * @throws OutOfRangeException when `$offset` is out of bounds
- *
- * @api
- */
- public function offsetSet(mixed $offset, mixed $value): void
- {
- if (!$this->hasAllowedType($value)) {
- throw new InvalidArgumentException(
- sprintf(
- 'Parameter 2 must be an allowed type, %s given.',
- get_debug_type($value)
- )
- );
- }
- /** @psalm-suppress PossiblyNullArgument */
- parent::offsetSet($offset, $value);
- }
-
- /**
- * Prepend items at the start of the list.
- *
- * @param AllowedType ...$values One or more items to prepend
- *
- * @return void
- *
- * @throws InvalidArgumentException if `$value` is not of allowed type
- *
- * @api
- */
- public function prepend(mixed ...$values): void
- {
- /** @var array $values */
- foreach ($values as $count => $value) {
- if (!$this->hasAllowedType($value)) {
- throw new InvalidArgumentException(
- sprintf(
- 'Parameter %d must be an allowed type, %s given.',
- $count + 1,
- get_debug_type($value)
- )
- );
- }
- }
- foreach ($values as $value) {
- parent::unshift($value);
- }
- }
-
- /**
- * Push an item at the end of the list.
- *
- * @param AllowedType $value The item to push
- *
- * @return void
- *
- * @throws InvalidArgumentException if `$value` is not of allowed type
- *
- * @api
- */
- public function push(mixed $value): void
- {
- if (!$this->hasAllowedType($value)) {
- throw new InvalidArgumentException(
- sprintf(
- 'Parameter 1 must be an allowed type, %s given.',
- get_debug_type($value)
- )
- );
- }
- parent::push($value);
- }
-
- /**
- * Remove an item from the list.
- *
- * @param int $offset The item's index
- *
- * @return void
- *
- * @throws OutOfRangeException when `$offset` is out of bounds
- *
- * @api
- */
- public function remove(int $offset): void
- {
- $this->offsetUnset($offset);
- }
-
- /**
- * Get string representation of $this.
- *
- * @return string The string representation
- *
- * @internal
- */
- public function serialize(): string
- {
- return serialize($this->__serialize());
- }
-
- /**
- * Set an item at the specified index.
- *
- * @param int $offset The item's index
- * @param AllowedType $value The item
- *
- * @return void
- *
- * @throws InvalidArgumentException if `$value` is not of allowed type
- *
- * @api
- */
- public function set(int $offset, mixed $value): void
- {
- $this->offsetSet($offset, $value);
- }
-
- /**
- * Return array representation of list.
- *
- * @return array Array of list items
- *
- * @api
- */
- public function toArray(): array
- {
- return iterator_to_array($this, true);
- }
-
- /**
- * Turn list into a type-sensitive collection.
- *
- * @return StrictCollection A type-sensitive collection of the list's items
- *
- * @api
- */
- public function toStrictCollection(): StrictCollection
- {
- $strictCollection = new StrictCollection($this->getAllowedTypes());
- foreach ($this->toArray() as $offset => $value) {
- $strictCollection[$offset] = $value;
- }
- return $strictCollection;
- }
-
- /**
- * Restore $this from string representation.
- *
- * @param string $data The string representation
- *
- * @return void
- *
- * @internal
- */
- public function unserialize($data): void
- {
- /** @var mixed[] $dataArray */
- $dataArray = unserialize($data);
- $this->__unserialize($dataArray);
- }
-
- /**
- * Prepend the list with an item.
- *
- * @param AllowedType $value The item to unshift
- *
- * @return void
- *
- * @throws InvalidArgumentException if `$value` is not of allowed type
- *
- * @api
- */
- public function unshift(mixed $value): void
- {
- if (!$this->hasAllowedType($value)) {
- throw new InvalidArgumentException(
- sprintf(
- 'Parameter 1 must be an allowed type, %s given.',
- get_debug_type($value)
- )
- );
- }
- parent::unshift($value);
- }
-
- /**
- * Create a type-sensitive, traversable list of items.
- *
- * @param string[] $allowedTypes Allowed data types of items (optional)
- *
- * If empty, all types are allowed.
- * Possible values are:
- * - "array"
- * - "bool"
- * - "callable"
- * - "countable"
- * - "float" or "double"
- * - "int" or "integer" or "long"
- * - "iterable"
- * - "null"
- * - "numeric"
- * - "object" or FQCN
- * - "resource"
- * - "scalar"
- * - "string"
- *
- * @return void
- *
- * @throws InvalidArgumentException if any value of `$allowedTypes` is not a string
- */
- public function __construct(array $allowedTypes = [])
- {
- $this->setAllowedTypes($allowedTypes);
- }
-
- /**
- * Get debug information for $this.
- *
- * @return mixed[] The debug information
- *
- * @internal
- */
- public function __debugInfo(): array
- {
- return $this->__serialize();
- }
-
- /**
- * Get array representation of $this.
- *
- * @return mixed[] The array representation
- *
- * @internal
- */
- public function __serialize(): array
- {
- return [
- 'StrictSplDatastructure::allowedTypes' => $this->getAllowedTypes(),
- 'StrictSplDatastructure::dllist' => $this->toArray(),
- 'StrictSplDatastructure::flags' => $this->getIteratorMode()
- ];
- }
-
- /**
- * Restore $this from array representation.
- *
- * @param mixed[] $data The array representation
- *
- * @return void
- *
- * @internal
- *
- * @psalm-suppress MethodSignatureMismatch
- */
- public function __unserialize(array $data): void
- {
- /** @var string[] $allowedTypes */
- $allowedTypes = $data['StrictSplDatastructure::allowedTypes'];
- $this->setAllowedTypes($allowedTypes);
- /** @var array $values */
- $values = $data['StrictSplDatastructure::dllist'];
- $this->append(...$values);
- /** @var int $flags */
- $flags = $data['StrictSplDatastructure::flags'];
- $this->setIteratorMode($flags);
- }
-}
diff --git a/doc/files/src/DataStructures/StrictStack.php.txt b/doc/files/src/DataStructures/StrictStack.php.txt
index 8ec5cda..6c82907 100644
--- a/doc/files/src/DataStructures/StrictStack.php.txt
+++ b/doc/files/src/DataStructures/StrictStack.php.txt
@@ -24,7 +24,7 @@ declare(strict_types=1);
namespace OCC\Basics\DataStructures;
use OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException;
-use OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait;
+use OCC\Basics\DataStructures\Traits\StrictSplDoublyLinkedListTrait;
use RuntimeException;
use SplStack;
@@ -45,8 +45,8 @@ use SplStack;
*/
class StrictStack extends SplStack
{
- /** @use StrictSplDatastructureTrait */
- use StrictSplDatastructureTrait;
+ /** @use StrictSplDoublyLinkedListTrait */
+ use StrictSplDoublyLinkedListTrait;
/**
* Add an item to the stack.
@@ -69,7 +69,7 @@ class StrictStack extends SplStack
*
* @return AllowedType The unstacked item
*
- * @throws RuntimeException if the list is empty
+ * @throws RuntimeException if the stack is empty
*
* @api
*/
diff --git a/doc/files/src/DataStructures/Traits/StrictSplDatastructureTrait.php.txt b/doc/files/src/DataStructures/Traits/StrictSplDoublyLinkedListTrait.php.txt
similarity index 99%
rename from doc/files/src/DataStructures/Traits/StrictSplDatastructureTrait.php.txt
rename to doc/files/src/DataStructures/Traits/StrictSplDoublyLinkedListTrait.php.txt
index 6eb421f..73f34d1 100644
--- a/doc/files/src/DataStructures/Traits/StrictSplDatastructureTrait.php.txt
+++ b/doc/files/src/DataStructures/Traits/StrictSplDoublyLinkedListTrait.php.txt
@@ -49,7 +49,7 @@ use function unserialize;
* @template AllowedType of mixed
* @phpstan-require-extends SplDoublyLinkedList
*/
-trait StrictSplDatastructureTrait
+trait StrictSplDoublyLinkedListTrait
{
use TypeChecker {
setAllowedTypes as protected;
diff --git a/doc/files/src/ErrorHandlers/ThrowErrorException.php.txt b/doc/files/src/ErrorHandlers/ThrowErrorException.php.txt
index f9ff9af..271b77b 100644
--- a/doc/files/src/ErrorHandlers/ThrowErrorException.php.txt
+++ b/doc/files/src/ErrorHandlers/ThrowErrorException.php.txt
@@ -52,8 +52,12 @@ class ThrowErrorException
*
* @throws ErrorException if `error_reporting` is set to report the error
*/
- public function __invoke(int $errno = E_USER_ERROR, string $errstr = '', ?string $errfile = null, ?int $errline = null): bool
- {
+ public function __invoke(
+ int $errno = \E_USER_ERROR,
+ string $errstr = '',
+ ?string $errfile = null,
+ ?int $errline = null
+ ): bool {
if ((error_reporting() & $errno) > 0) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
diff --git a/doc/files/src/ErrorHandlers/TriggerExceptionError.php.txt b/doc/files/src/ErrorHandlers/TriggerExceptionError.php.txt
index feddf1c..16e9527 100644
--- a/doc/files/src/ErrorHandlers/TriggerExceptionError.php.txt
+++ b/doc/files/src/ErrorHandlers/TriggerExceptionError.php.txt
@@ -57,6 +57,6 @@ class TriggerExceptionError
$exception->getLine(),
$exception->getMessage()
);
- trigger_error($message, E_USER_ERROR);
+ trigger_error($message, \E_USER_ERROR);
}
}
diff --git a/doc/files/src/InterfaceTraits/ArrayAccessTrait.php.txt b/doc/files/src/InterfaceTraits/ArrayAccessTrait.php.txt
deleted file mode 100644
index 1b99e2c..0000000
--- a/doc/files/src/InterfaceTraits/ArrayAccessTrait.php.txt
+++ /dev/null
@@ -1,113 +0,0 @@
-
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-declare(strict_types=1);
-
-namespace OCC\Basics\InterfaceTraits;
-
-use ArrayAccess;
-
-/**
- * A generic implementation of the ArrayAccess interface.
- *
- * Internally it accesses the protected `$_data` array.
- *
- * @author Sebastian Meyer
- * @package Basics\InterfaceTraits
- *
- * @api
- *
- * @template TValue of mixed
- * @implements ArrayAccess
- * @phpstan-require-implements ArrayAccess
- */
-trait ArrayAccessTrait
-{
- /**
- * Holds the array-accessible data.
- *
- * @var TValue[]
- *
- * @internal
- */
- protected array $_data = [];
-
- /**
- * Check if the specified offset exists.
- *
- * @param array-key $offset The offset to check for
- *
- * @return bool Whether the offset exists
- *
- * @api
- */
- public function offsetExists(mixed $offset): bool
- {
- return isset($this->_data[$offset]);
- }
-
- /**
- * Retrieve data at the specified offset.
- *
- * @param array-key $offset The offset to retrieve
- *
- * @return ?TValue The value at the offset or NULL if invalid
- *
- * @api
- */
- public function offsetGet(mixed $offset): mixed
- {
- return $this->_data[$offset] ?? null;
- }
-
- /**
- * Assign a value to the specified offset.
- *
- * @param ?array-key $offset The offset to assign to or NULL to append
- * @param TValue $value The value to set
- *
- * @return void
- *
- * @api
- */
- public function offsetSet(mixed $offset, mixed $value): void
- {
- if (is_null($offset)) {
- $this->_data[] = $value;
- } else {
- $this->_data[$offset] = $value;
- }
- }
-
- /**
- * Unset the specified offset.
- *
- * @param array-key $offset The offset to unset
- *
- * @return void
- *
- * @api
- */
- public function offsetUnset(mixed $offset): void
- {
- unset($this->_data[$offset]);
- }
-}
diff --git a/doc/files/src/InterfaceTraits/CountableTrait.php.txt b/doc/files/src/InterfaceTraits/CountableTrait.php.txt
deleted file mode 100644
index 3c231cc..0000000
--- a/doc/files/src/InterfaceTraits/CountableTrait.php.txt
+++ /dev/null
@@ -1,64 +0,0 @@
-
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-declare(strict_types=1);
-
-namespace OCC\Basics\InterfaceTraits;
-
-use Countable;
-
-/**
- * A generic implementation of the Countable interface.
- *
- * Internally it counts the values of the protected `$_data` array.
- *
- * @author Sebastian Meyer
- * @package Basics\InterfaceTraits
- *
- * @api
- *
- * @template TValue of mixed
- * @implements Countable
- * @phpstan-require-implements Countable
- */
-trait CountableTrait
-{
- /**
- * Holds the countable data.
- *
- * @var TValue[]
- *
- * @internal
- */
- protected array $_data = [];
-
- /**
- * Count the data items.
- *
- * @return int<0, max> The number of data items
- *
- * @api
- */
- public function count(): int
- {
- return count($this->_data);
- }
-}
diff --git a/doc/files/src/InterfaceTraits/IteratorAggregateTrait.php.txt b/doc/files/src/InterfaceTraits/IteratorAggregateTrait.php.txt
deleted file mode 100644
index 934fffe..0000000
--- a/doc/files/src/InterfaceTraits/IteratorAggregateTrait.php.txt
+++ /dev/null
@@ -1,65 +0,0 @@
-
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-declare(strict_types=1);
-
-namespace OCC\Basics\InterfaceTraits;
-
-use ArrayIterator;
-use IteratorAggregate;
-
-/**
- * A generic implementation of the IteratorAggregate interface.
- *
- * Internally it iterates over the protected `$_data` array.
- *
- * @author Sebastian Meyer
- * @package Basics\InterfaceTraits
- *
- * @api
- *
- * @template TValue of mixed
- * @implements IteratorAggregate
- * @phpstan-require-implements IteratorAggregate
- */
-trait IteratorAggregateTrait
-{
- /**
- * Holds the iterable data.
- *
- * @var TValue[]
- *
- * @internal
- */
- protected array $_data = [];
-
- /**
- * Retrieve an external iterator.
- *
- * @return ArrayIterator New iterator for the data array
- *
- * @api
- */
- public function getIterator(): ArrayIterator
- {
- return new ArrayIterator($this->_data);
- }
-}
diff --git a/doc/files/src/InterfaceTraits/IteratorTrait.php.txt b/doc/files/src/InterfaceTraits/IteratorTrait.php.txt
deleted file mode 100644
index 576e165..0000000
--- a/doc/files/src/InterfaceTraits/IteratorTrait.php.txt
+++ /dev/null
@@ -1,128 +0,0 @@
-
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-declare(strict_types=1);
-
-namespace OCC\Basics\InterfaceTraits;
-
-use Iterator;
-
-/**
- * A generic implementation of the Iterator interface.
- *
- * Internally it iterates over the protected `$_data` array.
- *
- * @author Sebastian Meyer
- * @package Basics\InterfaceTraits
- *
- * @api
- *
- * @template TValue of mixed
- * @implements Iterator
- * @phpstan-require-implements Iterator
- */
-trait IteratorTrait
-{
- /**
- * Holds the iterable data.
- *
- * @var TValue[]
- *
- * @internal
- */
- protected array $_data = [];
-
- /**
- * Return the current item.
- *
- * @return ?TValue The current item or NULL if invalid
- *
- * @api
- */
- public function current(): mixed
- {
- if ($this->valid()) {
- /** @var TValue */
- return current($this->_data);
- }
- return null;
- }
-
- /**
- * Return the current key.
- *
- * @return ?array-key The current key or NULL if invalid
- *
- * @api
- */
- public function key(): mixed
- {
- return key($this->_data);
- }
-
- /**
- * Move forward to next item.
- *
- * @return void
- *
- * @api
- */
- 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
- */
- public function rewind(): void
- {
- reset($this->_data);
- }
-
- /**
- * Check if current position is valid.
- *
- * @return bool Whether the current position is valid
- *
- * @api
- */
- public function valid(): bool
- {
- return !is_null($this->key());
- }
-}
diff --git a/doc/guides/changelog.html b/doc/guides/changelog.html
index e08dfdc..a78e8de 100644
--- a/doc/guides/changelog.html
+++ b/doc/guides/changelog.html
@@ -173,10 +173,35 @@