Update PHPDoc

This commit is contained in:
Sebastian Meyer 2024-01-24 22:45:04 +01:00
parent 7311da4b22
commit 7a8ac2f87a
8 changed files with 69 additions and 54 deletions

View File

@ -46,25 +46,7 @@ class StrictList extends SplDoublyLinkedList
use Getter; use Getter;
/** /**
* Defines the allowed types for items. * Defines the allowed data types for items.
*
* 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"
*
* Fully qualified class names (FQCN) can be specified instead of the
* generic type "object".
* *
* @var string[] * @var string[]
*/ */
@ -72,7 +54,6 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Add/insert a new item at the specified index. * Add/insert a new item at the specified index.
* @see SplDoublyLinkedList::add()
* *
* @param int $index The index where the new item is to be inserted * @param int $index The index where the new item is to be inserted
* @param AllowedType $item The new item for the index * @param AllowedType $item The new item for the index
@ -122,11 +103,11 @@ class StrictList extends SplDoublyLinkedList
} }
/** /**
* Check if item is an allowed type. * Check if the item's data type is allowed on the list.
* *
* @param AllowedType $item The item to check * @param AllowedType $item The item to check
* *
* @return bool Whether the item is an allowed type * @return bool Whether the item's data type is allowed
*/ */
public function isAllowedType(mixed $item): bool public function isAllowedType(mixed $item): bool
{ {
@ -138,7 +119,7 @@ class StrictList extends SplDoublyLinkedList
if (function_exists($function) && $function($item)) { if (function_exists($function) && $function($item)) {
return true; return true;
} }
$fqcn = '\\' . ltrim($type, '\\'); $fqcn = ltrim($type, '\\');
if (is_object($item) && is_a($item, $fqcn)) { if (is_object($item) && is_a($item, $fqcn)) {
return true; return true;
} }
@ -148,9 +129,8 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Magic getter method for $this->allowedTypes. * Magic getter method for $this->allowedTypes.
* @see Getter
* *
* @return string[] The list of allowed item types * @return string[] The list of allowed data types
* *
* @internal * @internal
*/ */
@ -161,7 +141,6 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Set the item at the specified index. * Set the item at the specified index.
* @see \ArrayAccess::offsetSet()
* *
* @param ?int $index The index being set or NULL to append * @param ?int $index The index being set or NULL to append
* @param AllowedType $item The new item for the index * @param AllowedType $item The new item for the index
@ -212,7 +191,6 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Push an item at the end of the list. * Push an item at the end of the list.
* @see SplDoublyLinkedList::push()
* *
* @param AllowedType $item The item to push * @param AllowedType $item The item to push
* *
@ -235,9 +213,8 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Get string representation of $this. * Get string representation of $this.
* @see \Serializable::serialize()
* *
* @return string String representation * @return string The string representation
*/ */
public function serialize(): string public function serialize(): string
{ {
@ -246,9 +223,8 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Restore $this from string representation. * Restore $this from string representation.
* @see \Serializable::unserialize()
* *
* @param string $data String representation * @param string $data The string representation
* *
* @return void * @return void
*/ */
@ -261,7 +237,6 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Prepend the list with an item. * Prepend the list with an item.
* @see SplDoublyLinkedList::unshift()
* *
* @param AllowedType $item The item to unshift * @param AllowedType $item The item to unshift
* *
@ -285,7 +260,22 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Create a type-sensitive, traversable list of items. * Create a type-sensitive, traversable list of items.
* *
* @param string[] $allowedTypes Allowed types of items (optional) * @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"
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
@ -302,7 +292,7 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Get debug information for $this. * Get debug information for $this.
* *
* @return mixed[] Array of debug information * @return mixed[] The debug information
* *
* @internal * @internal
*/ */
@ -314,7 +304,7 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Get array representation of $this. * Get array representation of $this.
* *
* @return mixed[] Array representation * @return mixed[] The array representation
* *
* @internal * @internal
*/ */
@ -330,7 +320,7 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Restore $this from array representation. * Restore $this from array representation.
* *
* @param mixed[] $data Array representation * @param mixed[] $data The array representation
* *
* @return void * @return void
* *

View File

@ -28,6 +28,9 @@ use RuntimeException;
/** /**
* A type-sensitive, taversable First In, First Out Queue (FIFO). * A type-sensitive, taversable First In, First Out Queue (FIFO).
* *
* Extends [\SplQueue](https://www.php.net/splqueue) with an option to specify
* the allowed data types for list items.
*
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package Basics\DataStructures * @package Basics\DataStructures
* *
@ -40,7 +43,6 @@ class StrictQueue extends StrictList
{ {
/** /**
* Dequeue an item from the queue. * Dequeue an item from the queue.
* @see \SplQueue::dequeue()
* *
* @return AllowedType The dequeued item * @return AllowedType The dequeued item
*/ */
@ -51,7 +53,6 @@ class StrictQueue extends StrictList
/** /**
* Add an item to the queue. * Add an item to the queue.
* @see \SplQueue::enqueue()
* *
* @param AllowedType $item The item to enqueue * @param AllowedType $item The item to enqueue
* *
@ -66,7 +67,6 @@ class StrictQueue extends StrictList
/** /**
* Set the mode of iteration. * Set the mode of iteration.
* @see \SplDoublyLinkedList::setIteratorMode()
* *
* @param int $mode The new iterator mode (0 or 1) * @param int $mode The new iterator mode (0 or 1)
* *
@ -90,7 +90,24 @@ class StrictQueue extends StrictList
/** /**
* Create a type-sensitive, traversable queue of items. * Create a type-sensitive, traversable queue of items.
* *
* @param string[] $allowedTypes Allowed types of items (optional) * @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"
*
* @throws \InvalidArgumentException
*/ */
public function __construct(array $allowedTypes = []) public function __construct(array $allowedTypes = [])
{ {

View File

@ -28,6 +28,9 @@ use RuntimeException;
/** /**
* A type-sensitive, taversable Last In, First Out Stack (LIFO). * A type-sensitive, taversable Last In, First Out Stack (LIFO).
* *
* Extends [\SplStack](https://www.php.net/splstack) with an option to specify
* the allowed data types for list items.
*
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package Basics\DataStructures * @package Basics\DataStructures
* *
@ -64,7 +67,6 @@ class StrictStack extends StrictList
/** /**
* Set the mode of iteration. * Set the mode of iteration.
* @see \SplDoublyLinkedList::setIteratorMode()
* *
* @param int $mode The new iterator mode (2 or 3) * @param int $mode The new iterator mode (2 or 3)
* *
@ -88,7 +90,24 @@ class StrictStack extends StrictList
/** /**
* Create a type-sensitive, traversable stack of items. * Create a type-sensitive, traversable stack of items.
* *
* @param string[] $allowedTypes Allowed types of items (optional) * @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"
*
* @throws \InvalidArgumentException
*/ */
public function __construct(array $allowedTypes = []) public function __construct(array $allowedTypes = [])
{ {

View File

@ -36,7 +36,7 @@ use ErrorException;
class ThrowErrorException class ThrowErrorException
{ {
/** /**
* Converts an internal PHP error into an ErrorException. * Convert an internal PHP error into an ErrorException.
* *
* @param int $errno The severity of the error * @param int $errno The severity of the error
* @param string $errstr The error message * @param string $errstr The error message

View File

@ -40,7 +40,6 @@ trait ArrayAccess
/** /**
* Whether the specified offset exists. * Whether the specified offset exists.
* @see \ArrayAccess::offsetExists()
* *
* @param mixed $offset The offset to check for * @param mixed $offset The offset to check for
* *
@ -53,7 +52,6 @@ trait ArrayAccess
/** /**
* Retrieve data at the specified offset. * Retrieve data at the specified offset.
* @see \ArrayAccess::offsetGet()
* *
* @param mixed $offset The offset to retrieve at * @param mixed $offset The offset to retrieve at
* *
@ -66,7 +64,6 @@ trait ArrayAccess
/** /**
* Assign a value to the specified offset. * Assign a value to the specified offset.
* @see \ArrayAccess::offsetSet()
* *
* @param mixed $offset The offset to assign to or NULL to append * @param mixed $offset The offset to assign to or NULL to append
* @param mixed $value The value to set * @param mixed $value The value to set
@ -84,7 +81,6 @@ trait ArrayAccess
/** /**
* Unset the specified offset. * Unset the specified offset.
* @see \ArrayAccess::offsetUnset()
* *
* @param mixed $offset The offset to unset * @param mixed $offset The offset to unset
* *

View File

@ -40,7 +40,6 @@ trait Countable
/** /**
* Count the data items. * Count the data items.
* @see \Countable::count()
* *
* @return int The number of data items * @return int The number of data items
*/ */

View File

@ -40,7 +40,6 @@ trait Iterator
/** /**
* Return the current item. * Return the current item.
* @see \Iterator::current()
* *
* @return mixed The current item or FALSE if invalid * @return mixed The current item or FALSE if invalid
*/ */
@ -51,7 +50,6 @@ trait Iterator
/** /**
* Return the current key. * Return the current key.
* @see \Iterator::key()
* *
* @return mixed The current key or NULL if invalid * @return mixed The current key or NULL if invalid
*/ */
@ -62,7 +60,6 @@ trait Iterator
/** /**
* Move forward to next item. * Move forward to next item.
* @see \Iterator::next()
* *
* @return void * @return void
*/ */
@ -73,7 +70,6 @@ trait Iterator
/** /**
* Rewind the iterator to the first item. * Rewind the iterator to the first item.
* @see \Iterator::rewind()
* *
* @return void * @return void
*/ */
@ -84,7 +80,6 @@ trait Iterator
/** /**
* Checks if current position is valid. * Checks if current position is valid.
* @see \Iterator::valid()
* *
* @return bool Whether the current position is valid * @return bool Whether the current position is valid
*/ */

View File

@ -42,7 +42,6 @@ trait IteratorAggregate
/** /**
* Retrieve an external iterator. * Retrieve an external iterator.
* @see \IteratorAggregate::getIterator()
* *
* @return ArrayIterator * @return ArrayIterator
*/ */