Improve phpDoc documentation

This commit is contained in:
Sebastian Meyer 2023-11-15 12:01:21 +01:00
parent bd4b72168f
commit 4b02d4f0e6
6 changed files with 36 additions and 33 deletions

View File

@ -1,3 +1,3 @@
Please read the excellent [GitHub Open Source Guide](https://opensource.guide/how-to-contribute/) on *How to Contribute on Open Source*. Please read the excellent [GitHub Open Source Guide](https://opensource.guide/how-to-contribute/) on *How to Contribute on Open Source*.
If you have any further questions just [open a new issue](https://github.com/opencultureconsulting/php-traits/issues/new) and I'll be happy to assist! If you have any further questions just [open a new issue](https://github.com/opencultureconsulting/php-basics/issues/new) and I'll be happy to assist!

View File

@ -43,29 +43,30 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Defines the allowed types for items. * Defines the allowed types for items.
* If empty, all types are allowed. *
* Possible values are: * If empty, all types are allowed.
* - "array" * Possible values are:
* - "bool" * - "array"
* - "callable" * - "bool"
* - "countable" * - "callable"
* - "float" or "double" * - "countable"
* - "int" or "integer" or "long" * - "float" or "double"
* - "iterable" * - "int" or "integer" or "long"
* - "null" * - "iterable"
* - "numeric" * - "null"
* - "object" or FQCN * - "numeric"
* - "resource" * - "object" or FQCN
* - "scalar" * - "resource"
* - "string" * - "scalar"
* Fully qualified class names (FQCN) can be specified instead of the * - "string"
* generic type "object". * Fully qualified class names (FQCN) can be specified instead of the
* generic type "object".
*/ */
protected array $allowedTypes = []; protected array $allowedTypes = [];
/** /**
* Add/insert a new item at the specified index. * Add/insert a new item at the specified index.
* @see SplDoublyLinkedList::add * @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 mixed $item The new item for the index * @param mixed $item The new item for the index
@ -151,7 +152,7 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Set the item at the specified index. * Set the item at the specified index.
* @see ArrayAccess::offsetSet * @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 mixed $item The new item for the index * @param mixed $item The new item for the index
@ -191,7 +192,7 @@ 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 * @see SplDoublyLinkedList::push()
* *
* @param mixed $item The item to push * @param mixed $item The item to push
* *
@ -209,7 +210,7 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Get string representation of $this. * Get string representation of $this.
* @see Serializable::serialize * @see Serializable::serialize()
* *
* @return string String representation * @return string String representation
*/ */
@ -220,7 +221,7 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Restore $this from string representation. * Restore $this from string representation.
* @see Serializable::unserialize * @see Serializable::unserialize()
* *
* @param string $data String representation * @param string $data String representation
* *
@ -233,7 +234,7 @@ class StrictList extends SplDoublyLinkedList
/** /**
* Prepend the list with an item. * Prepend the list with an item.
* @see SplDoublyLinkedList::unshift * @see SplDoublyLinkedList::unshift()
* *
* @param mixed $item The item to unshift * @param mixed $item The item to unshift
* *

View File

@ -39,7 +39,7 @@ class StrictQueue extends StrictList
{ {
/** /**
* Set the mode of iteration. * Set the mode of iteration.
* @see SplDoublyLinkedList::setIteratorMode * @see SplDoublyLinkedList::setIteratorMode()
* *
* @param int $mode The new iterator mode (0 or 1) * @param int $mode The new iterator mode (0 or 1)
* *

View File

@ -39,7 +39,7 @@ class StrictStack extends StrictList
{ {
/** /**
* Set the mode of iteration. * Set the mode of iteration.
* @see SplDoublyLinkedList::setIteratorMode * @see SplDoublyLinkedList::setIteratorMode()
* *
* @param int $mode The new iterator mode (2 or 3) * @param int $mode The new iterator mode (2 or 3)
* *

View File

@ -25,25 +25,26 @@ namespace OCC\Basics\Functions;
use ErrorException; use ErrorException;
/** /**
* Handles an internal PHP error and throws it as ErrorException. * Converts an internal PHP error into an ErrorException.
* @example set_error_handler('\\OCC\\Basics\\Functions\\throwErrorException'); *
* Usage: set_error_handler('\\OCC\\Basics\\Functions\\throwErrorException');
* *
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package opencultureconsulting/basics * @package opencultureconsulting/basics
* *
* @param int $severity The severity of the error * @param int $severity The severity of the error
* @param string $message The error message * @param string $message The error message
* @param ?string $filename The name of the file the error was raised in * @param ?string $file The name of the file the error was raised in
* @param ?int $line The number of the line the error was raised in * @param ?int $line The line number the error was raised in
* *
* @return bool Always returns FALSE when not throwing an exception * @return bool Always returns FALSE when not throwing an exception
* *
* @throws \ErrorException * @throws \ErrorException
*/ */
function throwErrorException(int $severity = E_ALL, string $message = '', ?string $filename = null, ?int $line = null): bool function throwErrorException(int $severity = E_ALL, string $message = '', ?string $file = null, ?int $line = null): bool
{ {
if (error_reporting() & $severity) { if (error_reporting() & $severity) {
throw new ErrorException($message, 0, $severity, $filename, $line); throw new ErrorException($message, 0, $severity, $file, $line);
} }
return false; return false;
} }

View File

@ -52,7 +52,8 @@ trait Singleton
/** /**
* This is a singleton class, thus the constructor is private. * This is a singleton class, thus the constructor is private.
* (Get an instance of this class by calling self::getInstance()) *
* Usage: Get an instance of this class by calling self::getInstance()
* *
* @param mixed ...$args Constructor parameters * @param mixed ...$args Constructor parameters
*/ */