- @@ -675,6 +681,8 @@ Possible values are:
diff --git a/.phpdoc/guide/changelog.rst b/.phpdoc/guide/changelog.rst
index b1abda1..3dd0437 100644
--- a/.phpdoc/guide/changelog.rst
+++ b/.phpdoc/guide/changelog.rst
@@ -54,7 +54,7 @@ v2.0.0
* Added new trait :php:trait:`OCC\Basics\Traits\OverloadingGetter`
* Added new trait :php:trait:`OCC\Basics\Traits\OverloadingSetter`
* Added new trait :php:trait:`OCC\Basics\Traits\TypeChecker`
-* Extended API for all datastructures (see :php:trait:`OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait`)
+* Extended API for all datastructures (see :php:trait:`OCC\Basics\DataStructures\Traits\StrictSplDoublyLinkedListTrait`)
* Introduced :php:class:`OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException` for strict datastructures
* Extended `documentation Common exception for type-sensitive datastructures. Exception thrown if a value does not adhere to the defined list of valid
data types.
A type-sensitive, traversable array.
+Holds items as key/value pairs where keys have to be valid array keys while values can be of any type. To restrict allowed data types for items, provide the constructor with an array of atomic types or fully qualified class @@ -250,6 +251,8 @@ names.
+ +It is considered a list if all keys are consecutive integers starting
from 0
.
0
.
0
.
+
+
+
0
.
+
+
+
@@ -1294,6 +1338,7 @@ from 0
.
+
0
.
+
+
0
.
+
0
.
+
+
0
.
>
Assign a value to the specified offset.
+Set the item at the specified offset.
public
- offsetSet(string|int|null $offset, TValue $value) : void
+ offsetSet(string|int|null $offset, AllowedType $value) : void
0
.
: string|int|null
The offset to assign to or NULL to append
+The offset being set
The value to set
+The new item for the offset
0
.
+
0
.
+
+
0
.
0
.
+
+
+
@@ -1602,6 +1691,7 @@ from 0
.
+
0
.
0
.
0
.
+
+
+
0
.
+
0
.
0
.
0
.
0
.
+
+
+
0
.
+
0
.
0
.
+
0
.
0
.
0
.
+
+
0
.
0
.
A type-sensitive, unsorted collection.
+Holds items as key/value pairs where keys have to be valid array keys while values can be of any type. To restrict allowed data types for items, provide the constructor with an array of atomic types or fully qualified class @@ -247,6 +248,8 @@ names.
+ +It is considered a list if all keys are consecutive integers starting
from 0
.
0
.
0
.
+
0
.
+
+
0
.
+
0
.
+
+
0
.
+
0
.
0
.
+
+
0
.
0
.
+
0
.
0
.
0
.
+
0
.
0
.
0
.
+
+
0
.
A type-sensitive, taversable list.
+Extends \SplDoublyLinkedList with an option to restrict the allowed data types for list items by providing the constructor with an array of atomic types or fully qualified class names.
@@ -245,6 +246,8 @@ constructor with an array of atomic types or fully qualified class names. + +A type-sensitive, taversable queue (FIFO).
+Extends \SplQueue with an option to restrict the allowed data types for list items by providing the constructor with an array of atomic types or fully qualified class names.
@@ -245,6 +246,8 @@ array of atomic types or fully qualified class names. + +A type-sensitive, taversable stack (LIFO).
+Extends \SplStack with an option to restrict the allowed data types for list items by providing the constructor with an array of atomic types or fully qualified class names.
@@ -245,6 +246,8 @@ array of atomic types or fully qualified class names. + +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.
@@ -229,7 +230,9 @@ by type-checking to only allow specified data types on the list.Throws internal errors as exceptions.
+If registered as error handler, this converts an internal PHP error into an
ErrorException
. It respects the error_reporting
directive.
@@ -232,6 +233,8 @@ + +Table of Contents @@ -254,7 +257,7 @@
+ + + @@ -243,28 +246,28 @@
- - __invoke() + __invoke() : bool
@@ -264,7 +267,6 @@ - @@ -303,6 +305,7 @@+Parameters
+ +
- @@ -362,6 +365,8 @@
- Return values
bool @@ -485,7 +490,7 @@- Methods
- diff --git a/doc/classes/OCC-Basics-ErrorHandlers-TriggerExceptionError.html b/doc/classes/OCC-Basics-ErrorHandlers-TriggerExceptionError.html index b4530c9..c5ddbb2 100644 --- a/doc/classes/OCC-Basics-ErrorHandlers-TriggerExceptionError.html +++ b/doc/classes/OCC-Basics-ErrorHandlers-TriggerExceptionError.html @@ -205,6 +205,7 @@
-
- __invoke()
+- __invoke()
Triggers errors for uncaught exceptions.
+@@ -433,7 +438,7 @@ converts it into an internal PHP error of severity If registered as exception handler, this catches an uncaught exception and converts it into an internal PHP error of severity
E_USER_ERROR
.@@ -232,6 +233,8 @@ converts it into an internal PHP error of severityE_U + +
Table of Contents @@ -254,7 +257,7 @@ converts it into an internal PHP error of severity
E_U
- - __invoke() + __invoke() : void
@@ -264,7 +267,6 @@ converts it into an internal PHP error of severityE_U - @@ -303,6 +305,7 @@ converts it into an internal PHP error of severity
E_U
+Parameters
- @@ -319,6 +322,8 @@ converts it into an internal PHP error of severity
E_U + +
E_U
- Methods
- diff --git a/doc/classes/OCC-Basics-Interfaces-ArrayAccessTrait.html b/doc/classes/OCC-Basics-Interfaces-ArrayAccessTrait.html index dc73e22..86328d4 100644 --- a/doc/classes/OCC-Basics-Interfaces-ArrayAccessTrait.html +++ b/doc/classes/OCC-Basics-Interfaces-ArrayAccessTrait.html @@ -189,6 +189,7 @@
-
- __invoke()
+- __invoke()
A generic implementation of the ArrayAccess interface.
+@@ -217,7 +218,9 @@ Internally it accesses the protected
$_data
array.+ + @@ -243,7 +246,7 @@
- - offsetExists() + offsetExists() : bool
- Check if the specified offset exists.
- - offsetGet() + offsetGet() : TValue|null
- Retrieve data at the specified offset.
- - offsetSet() + offsetSet() : void
- Assign a value to the specified offset.
- - offsetUnset() + offsetUnset() : void
@@ -315,6 +318,7 @@ +Parameters
+
- @@ -330,6 +334,8 @@ + +
- Return values
bool @@ -370,6 +376,7 @@ +Parameters
- @@ -385,6 +392,8 @@ + +
@@ -609,10 +624,10 @@ Return values
TValue|null @@ -425,6 +434,7 @@ +Parameters
- @@ -450,6 +460,8 @@ + +
Parameters
- @@ -497,6 +510,8 @@ + +
- Methods
- diff --git a/doc/classes/OCC-Basics-Interfaces-CountableTrait.html b/doc/classes/OCC-Basics-Interfaces-CountableTrait.html index ea85a61..213bef8 100644 --- a/doc/classes/OCC-Basics-Interfaces-CountableTrait.html +++ b/doc/classes/OCC-Basics-Interfaces-CountableTrait.html @@ -189,6 +189,7 @@
A generic implementation of the Countable interface.
+@@ -217,7 +218,9 @@ Internally it counts the values of the protected
$_data
array.+ + + @@ -243,7 +246,7 @@
- - count() + count() : int<0, max>
@@ -296,6 +299,9 @@ + + +- Return values
@@ -418,7 +424,7 @@- Methods
- diff --git a/doc/classes/OCC-Basics-Interfaces-IteratorAggregateTrait.html b/doc/classes/OCC-Basics-Interfaces-IteratorAggregateTrait.html index 8827683..df9fed6 100644 --- a/doc/classes/OCC-Basics-Interfaces-IteratorAggregateTrait.html +++ b/doc/classes/OCC-Basics-Interfaces-IteratorAggregateTrait.html @@ -189,6 +189,7 @@
A generic implementation of the IteratorAggregate interface.
+@@ -217,7 +218,9 @@ Internally it iterates over the protected
$_data
array.+ + + @@ -243,42 +246,42 @@
- - getIterator() + getIterator() : ArrayIterator<string|int, TValue>
@@ -296,6 +299,9 @@ + + +- Return values
@@ -418,7 +424,7 @@- Methods
- diff --git a/doc/classes/OCC-Basics-Interfaces-IteratorTrait.html b/doc/classes/OCC-Basics-Interfaces-IteratorTrait.html index b0ede7b..22869eb 100644 --- a/doc/classes/OCC-Basics-Interfaces-IteratorTrait.html +++ b/doc/classes/OCC-Basics-Interfaces-IteratorTrait.html @@ -189,6 +189,7 @@
A generic implementation of the Iterator interface.
+@@ -217,7 +218,9 @@ Internally it iterates over the protected
$_data
array.+ + + @@ -242,14 +245,14 @@ a context where it normally would not be accessible.
- - current() + current() : TValue|null
- Return the current item.
- - key() + key() : string|int|null
- Return the current key.
- - next() + next() : void
- Move forward to next item.
- - prev() + prev() : void
- Move back to previous item.
- - rewind() + rewind() : void
- Rewind the iterator to the first item.
- - valid() + valid() : bool
@@ -331,6 +334,9 @@ + + +Return values
@@ -374,6 +380,9 @@ + + +Return values
@@ -417,6 +426,9 @@ + + + @@ -452,6 +464,9 @@ + + + @@ -487,6 +502,9 @@ + + + @@ -522,6 +540,9 @@ + + +Return values
@@ -644,12 +665,12 @@- Methods
- diff --git a/doc/classes/OCC-Basics-Traits-Getter.html b/doc/classes/OCC-Basics-Traits-Getter.html index 45d28e8..532b3b4 100644 --- a/doc/classes/OCC-Basics-Traits-Getter.html +++ b/doc/classes/OCC-Basics-Traits-Getter.html @@ -189,6 +189,7 @@
Reads data from inaccessible properties by using magic methods.
+- To make a
protected
orprivate
property readable, provide a method named_magicGet{Property}()
which handles the reading. Replace{Property}
in the method's name with the name of the actual property (with an uppercase @@ -216,7 +217,9 @@ a context where it normally would not be accessible.+ + @@ -238,14 +241,14 @@ as property names.
- - __get() + __get() : mixed
- Read data from an inaccessible property.
- - __isset() + __isset() : bool
@@ -298,6 +301,7 @@ a context where it normally would not be accessible.+Parameters
+ +
- @@ -330,6 +334,8 @@ a context where it normally would not be accessible.
Return values
mixed @@ -368,6 +374,7 @@ a context where it normally would not be accessible.+Parameters
+
- @@ -383,6 +390,8 @@ a context where it normally would not be accessible. + +
Return values
bool @@ -504,8 +513,8 @@ a context where it normally would not be accessible.- Methods
- diff --git a/doc/classes/OCC-Basics-Traits-OverloadingGetter.html b/doc/classes/OCC-Basics-Traits-OverloadingGetter.html index c9b2c8a..0ca7f95 100644 --- a/doc/classes/OCC-Basics-Traits-OverloadingGetter.html +++ b/doc/classes/OCC-Basics-Traits-OverloadingGetter.html @@ -189,6 +189,7 @@
Overloads a class with readable magic properties.
+- Internally it reads the protected
$_data
array whose keys are interpreted as property names.@@ -212,7 +213,9 @@ as property names.
- - __get() + __get() : mixed
- Read data from an overloaded property.
- - __isset() + __isset() : bool
@@ -294,6 +297,7 @@ as property names.+Parameters
+ + @@ -238,14 +241,14 @@ as property names.
- @@ -309,6 +313,8 @@ as property names. + +
Return values
mixed @@ -347,6 +353,7 @@ as property names.+Parameters
+
- @@ -362,6 +369,8 @@ as property names. + +
Return values
bool @@ -483,8 +492,8 @@ as property names.- Methods
- diff --git a/doc/classes/OCC-Basics-Traits-OverloadingSetter.html b/doc/classes/OCC-Basics-Traits-OverloadingSetter.html index 6093885..fe3ae4a 100644 --- a/doc/classes/OCC-Basics-Traits-OverloadingSetter.html +++ b/doc/classes/OCC-Basics-Traits-OverloadingSetter.html @@ -189,6 +189,7 @@
Overloads a class with writable magic properties.
+- Internally it writes the protected
$_data
array whose keys are interpreted as property names.@@ -212,7 +213,9 @@ as property names.
- - __set() + __set() : void
- Write data to an overloaded property.
- - __unset() + __unset() : void
@@ -294,6 +297,7 @@ as property names.+Parameters
- @@ -319,6 +323,8 @@ as property names. + +
+ Parameters
- @@ -364,6 +371,8 @@ as property names. + +
Writes data to inaccessible properties by using magic methods.
+To make a protected
or private
property writable, provide a method named
_magicSet{Property}()
which handles the writing. Replace {Property}
in
the method's name with the name of the actual property (with an uppercase
@@ -216,7 +217,9 @@ to in a context where it normally would not be accessible.
Allows just a single instance of the class using this trait.
+Get the singleton by calling the static method getInstance()
.
If there is no object yet, the constructor is called with the same arguments
as getInstance()
. Any later call will just return the already instantiated
@@ -213,7 +214,9 @@ as private
to prevent direct instantiation of t
private
to prevent direct instantiation of t
private
to prevent direct instantiation of t
+
private
to prevent direct instantiation of t
private
to prevent direct instantiation of t
+
+
private
to prevent direct instantiation of t
+
private
to prevent direct instantiation of t
private
to prevent direct instantiation of t
A generic data type checker.
+This allows to set a list of allowed atomic data types and fully qualified class names. It also provides a method to check if a value's data type matches at least one of these types.
@@ -210,7 +211,9 @@ matches at least one of these types.PHP Basics
+Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com
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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
PHP Basics Copyright (C) 2024 Sebastian Meyer sebastian.meyer@opencultureconsulting.com 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
@@ -193,6 +194,8 @@ along with this program. If not, see http
+
+
Breaking Changes:
+ Breaking Changes: New Features: New Features:
+ Breaking Changes:
+ Breaking Changes: Interfaces
- traits renamed and moved to different namespace Interfaces
+ traits renamed and moved to different namespace Prefixed internal methods for Getter
+ Prefixed internal methods for Getter
and Setter
with
- New Features: New Features:
+ Breaking Changes:
+ Breaking Changes: Changed the constructor's signature for all DataStructures
+ Changed the constructor's signature for all DataStructures
to improve compatibility with
-the corresponding SPL datastructures New Features:
+ New Features: Initial Release
+ Initial Release The datastructures in this package are derived from their respective Standard PHP Library (SPL) counterparts which they extend by the option to control the data types of items those
+
+ The datastructures in this package are derived from their respective Standard PHP Library (SPL) counterparts which they extend by the option to control the data types of items those
datastructures can hold. To restrict allowed data types for items, provide the constructor with an array of atomic types or fully qualified
-class names you want to allow as item types. Available atomic types are Trying to add an item with a data type not on the list of allowed types to a strict datastructure will result in an
-InvalidDataTypeException
+
+
+ To restrict allowed data types for items provide the constructor with an array of atomic types or fully qualified class
+names (FQCN) you want to allow as item types. Available atomic types are All strict datastructures inherit the implementation of the \ArrayAccess,
+
+
+ Trying to add an item with a data type not on the list of allowed types to a strict datastructure will result in an
+InvalidDataTypeException
+ being thrown. All strict datastructures inherit the implementation of the \ArrayAccess,
\Countable and \Serializable interfaces. All
-but Examples: Examples: A type-sensitive, unsorted collection of items. Holds items as key/value pairs where keys identify the items and have to be valid array keys while values can be of any
+
+ A type-sensitive, unsorted collection of items.
+ Holds items as key/value pairs where keys identify the items and have to be valid array keys while values can be of any
controlled type. The collection can be accessed like an array, but not traversed because it has no particular order. Internally it holds the items in the Internally it holds the items in the A type-sensitive, traversable array of items. Holds items as key/value pairs where keys identify the items and have to be valid array keys while values can be of any
+
+ A type-sensitive, traversable array of items.
+ Holds items as key/value pairs where keys identify the items and have to be valid array keys while values can be of any
controlled type. The array can be accessed and traversed just like any other array. Internally it holds the items in the Internally it holds the items in the A type-sensitive, taversable list of items. Extends \SplDoublyLinkedList with an option to restrict the allowed data
+
+ A type-sensitive, taversable list of items.
+ Extends \SplDoublyLinkedList with an option to restrict the allowed data
types for list items. The list can be accessed and traversed like an array, but has only consecutive numerical keys. A type-sensitive, taversable queue (FIFO) of items. Extends \SplQueue with an option to restrict the allowed data types for queue items.
+
+ A type-sensitive, taversable queue (FIFO) of items.
+ Extends \SplQueue with an option to restrict the allowed data types for queue items.
The queue can be accessed and traversed like an array, but has only consecutive numerical keys. Traversal follows the
first-in, first-out (FIFO) principle meaning that items are returned in the same order they were added to the queue. It is recommended to use the It is recommended to use the A type-sensitive, taversable stack (LIFO) of items. Extends \SplStack with an option to restrict the allowed data types for stack items.
+
+ A type-sensitive, taversable stack (LIFO) of items.
+ Extends \SplStack with an option to restrict the allowed data types for stack items.
The stack can be accessed and traversed like an array, but has only consecutive numerical keys. Traversal follows the
last-in, first-out (LIFO) principle meaning that items are returned in the reversed order they were added to the stack. It is recommended to use the It is recommended to use the Throws internal errors as exceptions. If registered as error handler, this handles an internal PHP error by converting it into an \ErrorException. It respects the error_reporting
+
+ Throws internal errors as exceptions.
+ If registered as error handler, this handles an internal PHP error by converting it into an \ErrorException. It respects the error_reporting
directive by only throwing an exception if the severity of the internal error is the same or higher than the setting. Usage: Usage: By design user-defined error handlers can't handle errors of severity By design user-defined error handlers can't handle errors of severity Triggers errors for uncaught exceptions. If registered as exception handler, this catches an uncaught exception and converts it into an internal PHP error of
-severity Usage: Triggers errors for uncaught exceptions.
+ If registered as exception handler, this catches an uncaught exception and converts it into an internal PHP error of
+severity Usage: The package currently contains classes for Typed Datastructures
-, Error and Exception Handlers
-, multiple Interface Traits
-, and
-more generic Traits
- for common use cases. They share the same design principles like property and method naming
+
+ The package currently contains classes for Typed Datastructures, Error and Exception Handlers, multiple Interface Traits, and
+more generic Traits for common use cases. They share the same design principles like property and method naming
schema, the highest coding standards of PHPStan and Psalm, and full
-PSR-12 compliance to make sure they can be combined and easily re-used in
-other projects. This package contains some traits implementing common interfaces, which can easily be used in any class that internally
+
+ This package contains some traits implementing common interfaces, which can easily be used in any class that internally
uses an array for holding its properties or data. They also share the same internal logic to allow combining multiple
traits within the same class. Internally all interface traits use the Internally all interface traits use the A generic implementation of the ArrayAccess interface. The \ArrayAccess interface allows objects to be accessed like arrays. Usage: A generic implementation of the ArrayAccess interface.
+ The \ArrayAccess interface allows objects to be accessed like arrays. Usage: A generic implementation of the Countable interface. The \Countable interface allows objects to be used with the count() function. Usage: A generic implementation of the Countable interface.
+ The \Countable interface allows objects to be used with the count() function. Usage: A generic implementation of the IteratorAggregate interface. The \IteratorAggregate interface creates an external \ArrayIterator for traversing the object's internal data array. Usage: A generic implementation of the IteratorAggregate interface.
+ The \IteratorAggregate interface creates an external \ArrayIterator for traversing the object's internal data array. Usage: A generic implementation of the Iterator interface. The \Iterator interface creates an internal iterator for traversing the object's data
+
+ A generic implementation of the Iterator interface.
+ The \Iterator interface creates an internal iterator for traversing the object's data
array. Usage: Usage: This package provides a number of generic traits like different getter and setter methods, an implementation of the
+
+ This package provides a number of generic traits like different getter and setter methods, an implementation of the
singleton design pattern and some little helpers. Those traits are too small to justify their own packages and most of them
-are dependencies of the Typed Datastructures
- and Interface Traits
- anyway. Reads data from inaccessible properties by using magic methods. To make a Reads data from inaccessible properties by using magic methods.
+ To make a Trying to access an undefined property or a property without corresponding "magic" getter method will result in an
-\InvalidArgumentException. Example: If the property is named Trying to access an undefined property or a property without corresponding "magic" getter method will result in an
+\InvalidArgumentException being thrown. Example: If the property is named Writes data to inaccessible properties by using magic methods. To make a Writes data to inaccessible properties by using magic methods.
+ To make a Trying to access an undefined property or a property without corresponding "magic" setter method will result in an
-\InvalidArgumentException. Example: If the property is named Trying to access an undefined property or a property without corresponding "magic" setter method will result in an
+\InvalidArgumentException being thrown. Example: If the property is named Overloads a class with readable virtual properties. It reads a protected internal array whose keys are interpreted as property names. Trying to access an undefined virtual property will not issue any warning or error, but return Example: Reading Overloads a class with readable virtual properties.
+ It reads a protected internal array whose keys are interpreted as property names. Trying to access an undefined virtual property will not issue any warning or error, but return Example: Reading Internally it uses the Internally it uses the Overloads a class with writable virtual properties. It writes a protected internal array whose keys are interpreted as property names. Trying to access a previously undefined virtual property will create a new one with the given name. Example: Overloads a class with writable virtual properties.
+ It writes a protected internal array whose keys are interpreted as property names. Trying to access a previously undefined virtual property will create a new one with the given name. Example: Internally it uses the Internally it uses the Allows just a single instance of the class using this trait. Get the singleton by calling the static method Allows just a single instance of the class using this trait.
+ Get the singleton by calling the static method In order for this to work as expected, the constructor has to be implemented as In order for this to work as expected, the constructor has to be implemented as A generic data type checker. This allows to set a list of allowed atomic data types and fully qualified class names. It also provides a method to
+
+ A generic data type checker.
+ This allows to set a list of allowed atomic data types and fully qualified class names. It also provides a method to
check if a value's data type matches at least one of these types. Available atomic types are Available atomic types are The PHP Basics are a library package, not a stand-alone application. The following documentation of requirements and
+
+ The PHP Basics
+ are a library package, not a stand-alone application. The following documentation of requirements and
installation procedures describes how to make use of the classes and traits within your own application. For a detailed
-description of the package's contents have a look at the Overview
- page. The intended and recommended way of re-using this package is via Composer. The following
+
+ The intended and recommended way of using this package is via Composer. The following
command will get you the latest version and make it a dependency of your project. It will also register all classes and
traits with the autoloader to make them available inside the application. If you want to use a specific version other than the latest available for your environment, you can do so by appending
+
+
+ If you want to use a specific version other than the latest available for your environment, you can do so by appending
the desired version constraint: All available versions as well as further information about Requirements
- and dependencies can be found on
+
+ All available versions as well as further information about Requirements and dependencies can be found on
Packagist. Alternatively, you can fetch the files from GitHub and add
+
+ Alternatively, you can fetch the files from GitHub and add
them to your project manually. The best way is by cloning the repository, because then you can easily update to a newer
version by just pulling the changes and checking out a different version tag. If you want to use a specific version other than the latest development state, you have to specify the desired tag as
+
+
+ If you want to use a specific version other than the latest development state, you have to specify the desired tag as
well: Be aware that you also need to make the classes and traits available in your application by either adding them to your
+
+ Be aware that you also need to make the classes and traits available in your application by either adding them to your
autoloader or by including all files individually in PHP. As a last resort you can also just download the files. You can find all available versions as well as the current
+
+ As a last resort you can also just download the files. You can find all available versions as well as the current
development state on the GitHub release page. This package requires at least PHP 8.1
+. It is highly recommended to use Composer for dependency management and autoloading,
+although it is technically not strictly required for using any of these classes and traits. But it certainly makes it a
+lot easier! This package requires at least PHP 8.1. It is highly recommended to use Composer for dependency management and autoloading,
-although it is technically not strictly required for re-using any of these classes and traits. But it certainly
-makes it a lot easier! This package does not have any external dependencies. This package does not have any external dependencies.
Table of Contents
diff --git a/doc/files/src-datastructures-strictarray.html b/doc/files/src-datastructures-strictarray.html
index 2ee0f29..4a4072f 100644
--- a/doc/files/src-datastructures-strictarray.html
+++ b/doc/files/src-datastructures-strictarray.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-datastructures-strictcollection.html b/doc/files/src-datastructures-strictcollection.html
index 02bc36c..e9535f0 100644
--- a/doc/files/src-datastructures-strictcollection.html
+++ b/doc/files/src-datastructures-strictcollection.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-datastructures-strictlist.html b/doc/files/src-datastructures-strictlist.html
index 6aa1ef7..39a171e 100644
--- a/doc/files/src-datastructures-strictlist.html
+++ b/doc/files/src-datastructures-strictlist.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-datastructures-strictqueue.html b/doc/files/src-datastructures-strictqueue.html
index 9110604..151ca4c 100644
--- a/doc/files/src-datastructures-strictqueue.html
+++ b/doc/files/src-datastructures-strictqueue.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-datastructures-strictstack.html b/doc/files/src-datastructures-strictstack.html
index 08cf2f7..4f68f44 100644
--- a/doc/files/src-datastructures-strictstack.html
+++ b/doc/files/src-datastructures-strictstack.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-datastructures-traits-strictspldoublylinkedlisttrait.html b/doc/files/src-datastructures-traits-strictspldoublylinkedlisttrait.html
index 0e47876..f7c6165 100644
--- a/doc/files/src-datastructures-traits-strictspldoublylinkedlisttrait.html
+++ b/doc/files/src-datastructures-traits-strictspldoublylinkedlisttrait.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-errorhandlers-throwerrorexception.html b/doc/files/src-errorhandlers-throwerrorexception.html
index 4752b34..a4b8b2a 100644
--- a/doc/files/src-errorhandlers-throwerrorexception.html
+++ b/doc/files/src-errorhandlers-throwerrorexception.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-errorhandlers-triggerexceptionerror.html b/doc/files/src-errorhandlers-triggerexceptionerror.html
index 9789a1d..4dacd75 100644
--- a/doc/files/src-errorhandlers-triggerexceptionerror.html
+++ b/doc/files/src-errorhandlers-triggerexceptionerror.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-interfaces-arrayaccesstrait.html b/doc/files/src-interfaces-arrayaccesstrait.html
index ea05ad9..084e8e3 100644
--- a/doc/files/src-interfaces-arrayaccesstrait.html
+++ b/doc/files/src-interfaces-arrayaccesstrait.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-interfaces-countabletrait.html b/doc/files/src-interfaces-countabletrait.html
index 90b67fe..62d5738 100644
--- a/doc/files/src-interfaces-countabletrait.html
+++ b/doc/files/src-interfaces-countabletrait.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-interfaces-iteratoraggregatetrait.html b/doc/files/src-interfaces-iteratoraggregatetrait.html
index aa27ae4..1f98269 100644
--- a/doc/files/src-interfaces-iteratoraggregatetrait.html
+++ b/doc/files/src-interfaces-iteratoraggregatetrait.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-interfaces-iteratortrait.html b/doc/files/src-interfaces-iteratortrait.html
index 81a5d7d..b03fa08 100644
--- a/doc/files/src-interfaces-iteratortrait.html
+++ b/doc/files/src-interfaces-iteratortrait.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-traits-getter.html b/doc/files/src-traits-getter.html
index d53a09f..c2ccd8a 100644
--- a/doc/files/src-traits-getter.html
+++ b/doc/files/src-traits-getter.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-traits-overloadinggetter.html b/doc/files/src-traits-overloadinggetter.html
index 4efa2e7..b05c8c9 100644
--- a/doc/files/src-traits-overloadinggetter.html
+++ b/doc/files/src-traits-overloadinggetter.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-traits-overloadingsetter.html b/doc/files/src-traits-overloadingsetter.html
index e58e6a7..5d388e7 100644
--- a/doc/files/src-traits-overloadingsetter.html
+++ b/doc/files/src-traits-overloadingsetter.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-traits-setter.html b/doc/files/src-traits-setter.html
index 119f478..cf9bde9 100644
--- a/doc/files/src-traits-setter.html
+++ b/doc/files/src-traits-setter.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-traits-singleton.html b/doc/files/src-traits-singleton.html
index 7c82c71..c118915 100644
--- a/doc/files/src-traits-singleton.html
+++ b/doc/files/src-traits-singleton.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src-traits-typechecker.html b/doc/files/src-traits-typechecker.html
index 8501d80..275c3d5 100644
--- a/doc/files/src-traits-typechecker.html
+++ b/doc/files/src-traits-typechecker.html
@@ -176,6 +176,7 @@
Table of Contents
diff --git a/doc/files/src/DataStructures/StrictArray.php.txt b/doc/files/src/DataStructures/StrictArray.php.txt
index bd590ea..7a05194 100644
--- a/doc/files/src/DataStructures/StrictArray.php.txt
+++ b/doc/files/src/DataStructures/StrictArray.php.txt
@@ -83,7 +83,7 @@ class StrictArray extends StrictCollection implements Iterator
*/
public function pop(): mixed
{
- if ($this->count() === 0) {
+ if (count($this->_data) === 0) {
throw new RuntimeException(
'Cannot return last item: array is empty.'
);
@@ -126,7 +126,7 @@ class StrictArray extends StrictCollection implements Iterator
*/
public function shift(): mixed
{
- if ($this->count() === 0) {
+ if (count($this->_data) === 0) {
throw new RuntimeException(
'Cannot return first item: array is empty.'
);
diff --git a/doc/guides/changelog.html b/doc/guides/changelog.html
index a78e8de..50284ca 100644
--- a/doc/guides/changelog.html
+++ b/doc/guides/changelog.html
@@ -169,18 +169,55 @@
Changelog
+ Changelog
v2.1.0
+ v2.1.0
+
+
+
@@ -191,7 +228,10 @@
-
@@ -203,33 +243,47 @@
v2.0.0
+ v2.0.0
+
+
+
-
+OCC\Basics\InterfaceTraits\ArrayAccess -> OCC\Basics\Interfaces\ArrayAccessTrait
+
OCC\Basics\InterfaceTraits\ArrayAccess -> OCC\Basics\Interfaces\ArrayAccessTrait
OCC\Basics\InterfaceTraits\Countable -> OCC\Basics\Interfaces\CountableTrait
OCC\Basics\InterfaceTraits\IteratorAggregate -> OCC\Basics\Interfaces\IteratorAggregateTrait
-OCC\Basics\InterfaceTraits\Iterator -> OCC\Basics\Interfaces\IteratorTrait
_
to avoid confusion with regular class methods// old methods
+
_
+ to avoid confusion with regular class methods
+// old methods
function magicGet{Property}(): mixed
-function magicSet{Property}(mixed $value): void
+// new methods
+function magicSet{Property}(mixed $value): void
// new methods
function _magicGet{Property}(): mixed
-function _magicSet{Property}(mixed $value): void
@@ -251,7 +305,7 @@ function _magicSet{Property}(mixed $value): void
v1.1.0
+ v1.1.0
+
+
+
-
// old constructor signature
-public function __construct(iterable $items = [], array $allowedTypes = [])
// new constructor signature
-public function __construct(array $allowedTypes = [])
+// old constructor signature
+public function __construct(iterable $items = [], array $allowedTypes = [])
+
// new constructor signature
+public function __construct(array $allowedTypes = [])
v1.0.1
+ v1.0.1
+
+
+
@@ -295,9 +359,12 @@ public function __construct(array $allowedTypes = [])
v1.0.0
+ v1.0.0
+
+
+ Documentation
+ Documentation
-
-
-
Typed Datastructures
+ Typed Datastructures
array
, bool
, callable
, countable
,
-float
/ double
, int
/ integer
/ long
, iterable
, null
, numeric
, object
, resource
, scalar
and
-string
.array
+, bool
+, callable
+, countable
+,
+float
+ (or double
+), int
+ (or integer
+ or long
+), iterable
+, null
+, numeric
+, object
+, resource
+, scalar
+
+and string
.StrictCollection
also implement a \Traversable interface.
+but // create a collection of strings
-$stringCollection = new StrictCollection(['string']);
// create a queue of PSR-15 middlewares
-$middlewareQueue = new StrictQueue(['Psr\Http\Server\MiddlewareInterface']);
StrictCollection
+ also implement a \Traversable interface.
+
+
+
+// create a collection of strings
+$stringCollection = new StrictCollection(['string']);
+// create a queue of PSR-15 middlewares
+$middlewareQueue = new StrictQueue(['Psr\Http\Server\MiddlewareInterface']);
StrictCollection
+ StrictCollection
- $_data
array, the same as most Interface Traits
- and Traits
- of this
+
+ $_data
+ array, the same as most Interface Traits and Traits of this
package.StrictArray
+ StrictArray
- $_data
array, the same as most Interface Traits
- and Traits
- of this
+
+ $_data
+ array, the same as most Interface Traits and Traits of this
package.StrictList
+ StrictList
- StrictQueue
+ StrictQueue
- StrictQueue::enqueue()
and StrictQueue::dequeue()
alias methods when working with a
+
+
+ StrictQueue::enqueue()
+ and StrictQueue::dequeue()
+ alias methods when working with a
queue, because those will ensure proper FIFO behavior and remove items while traversing.StrictStack
+ StrictStack
- StrictStack::stack()
and StrictStack::unstack()
alias methods when working with a
+
+
+ StrictStack::stack()
+ and StrictStack::unstack()
+ alias methods when working with a
stack, because those will ensure proper LIFO behavior and remove items while traversing.Error and Exception Handlers
+ Error and Exception Handlers
ThrowErrorException
+ ThrowErrorException
-
+
+ set_error_handler(new ThrowErrorException());
+
+set_error_handler(new ThrowErrorException());
E_ERROR
, E_PARSE
, E_CORE_ERROR
,
-E_CORE_WARNING
, E_COMPILE_ERROR
, E_COMPILE_WARNING
and most of E_STRICT
.E_ERROR
+, E_PARSE
+, E_CORE_ERROR
+,
+E_CORE_WARNING
+, E_COMPILE_ERROR
+, E_COMPILE_WARNING
+ and most of E_STRICT
+.TriggerExceptionError
+ TriggerExceptionError
- E_USER_ERROR
.
+
+ set_exception_handler(new TriggerExceptionError());
E_USER_ERROR
+.
+
+set_exception_handler(new TriggerExceptionError());
E_USER_ERROR
.
Overview
+ Overview
-
-
-
-
+
-
+
+
+
+
+
+
+
+Interface Traits
+ Interface Traits
$_data
array, the same as some Typed Datastructures
- and Traits
- of
+
+ $_data
+ array, the same as some Typed Datastructures and Traits of
this package.ArrayAccessTrait
+ ArrayAccessTrait
-
+class Foo implements ArrayAccess
+
+
+
+}class Foo implements ArrayAccess
{
use \OCC\Basics\Interfaces\ArrayAccessTrait;
-}
CountableTrait
+ CountableTrait
-
+class Foo implements Countable
+
+
+
+}class Foo implements Countable
{
use \OCC\Basics\Interfaces\CountableTrait;
-}
IteratorAggregateTrait
+ IteratorAggregateTrait
-
+class Foo implements IteratorAggregate
+
+
+
+}class Foo implements IteratorAggregate
{
use \OCC\Basics\Interfaces\IteratorAggregateTrait;
-}
IteratorTrait
+ IteratorTrait
-
+class Foo implements Iterator
+
+
+
+}class Foo implements Iterator
{
use \OCC\Basics\Interfaces\IteratorTrait;
-}
Traits
+ Traits
Getter
+ Getter
- protected
or private
property readable, provide a method named _magicGet{Property}()
which handles the
-reading. Replace {Property}
in the method's name with the name of the actual property (with an uppercase first
+
+ protected
+ or private
+ property readable, provide a method named _magicGet{Property}()
+ which handles the
+reading. Replace {Property}
+ in the method's name with the name of the actual property (with an uppercase first
letter).
+
+
+ $fooBar
, the "magic" method has to be _magicGetFooBar()
. This method is then
-called when $fooBar
is read in a context where it normally would not be accessible.
+
$fooBar
+, the "magic" method has to be _magicGetFooBar()
+. This method is then
+called when $fooBar
+ is read in a context where it normally would not be accessible.Setter
+ Setter
- protected
or private
property writable, provide a method named _magicSet{Property}()
which handles the
-writing. Replace {Property}
in the method's name with the name of the actual property (with an uppercase first
+
+ protected
+ or private
+ property writable, provide a method named _magicSet{Property}()
+ which handles the
+writing. Replace {Property}
+ in the method's name with the name of the actual property (with an uppercase first
letter).
+
+
+ $fooBar
, the "magic" method has to be _magicSetFooBar()
. This method is then
-called when $fooBar
is written to in a context where it normally would not be accessible.
+
$fooBar
+, the "magic" method has to be _magicSetFooBar()
+. This method is then
+called when $fooBar
+ is written to in a context where it normally would not be accessible.OverloadingGetter
+ OverloadingGetter
- NULL
instead.
+
+ Foo->bar
will return the value of Foo::$_data['bar']
.NULL
+ instead.
+
Foo->bar
+ will return the value of Foo::$_data['bar']
+.$_data
array, the same as some Typed Datastructures
- and all Interface Traits
- of this
+
+ $_data
+ array, the same as some Typed Datastructures and all Interface Traits of this
package.OverloadingSetter
+ OverloadingSetter
-
+
+ Foo->bar = 42;
will set Foo::$_data['bar']
to 42
.
+
Foo->bar = 42;
+ will set Foo::$_data['bar']
+ to 42
+.$_data
array, the same as some Typed Datastructures
- and all Interface Traits
- of this
+
+ $_data
+ array, the same as some Typed Datastructures and all Interface Traits of this
package.Singleton
+ Singleton
- getInstance()
. If there is no object yet, the constructor is called
-with the same arguments as getInstance()
. Any later call will just return the already instantiated object
+
+ getInstance()
+. If there is no object yet, the constructor is called
+with the same arguments as getInstance()
+. Any later call will just return the already instantiated object
(irrespective of the given arguments).private
to prevent direct
+
+ private
+ to prevent direct
instantiation of the class.TypeChecker
+ TypeChecker
- array
, bool
, callable
, countable
, float
/ double
, int
/ integer
/ long
,
-iterable
, null
, numeric
, object
, resource
, scalar
and string
.array
+, bool
+, callable
+, countable
+, float
+ (or double
+), int
+ (or integer
+ or
+long
+), iterable
+, null
+, numeric
+, object
+, resource
+, scalar
+ and string
+.User Guide
+ User Guide
-
-
+
+
+
+
+
+
-
+
-
Installation
+ Installation
Composer
+ Composer
-
- # This will install the latest stable version suitable for your project
composer require "opencultureconsulting/basics"
- # This will install the latest patch level version of 2.0 (i. e. >=2.0.0 && <2.1.0)
-composer require "opencultureconsulting/basics:~2.0"
+
+
+ # This will install the latest patch level version of 2.1 (i. e. >=2.1.0 && <2.2.0)
+composer require "opencultureconsulting/basics:~2.1"
Git
+ Git
-
- # This will clone the repository into the "basics" directory
git clone https://github.com/opencultureconsulting/php-basics.git basics
- # This will clone the repository state at version "2.0.0" into the "basics" directory
-git clone --branch=v2.0.0 https://github.com/opencultureconsulting/php-basics.git basics
+
+
+ # This will clone the repository state at version "2.1.0" into the "basics" directory
+git clone --branch=v2.1.0 https://github.com/opencultureconsulting/php-basics.git basics
Download
+ Download
- Requirements
+ Requirements
Environment
+ Environment
+
+
+ Dependencies
+ Dependencies
+
+
+