Compare commits
7 Commits
c8ebed23ed
...
d0dcdb5110
Author | SHA1 | Date |
---|---|---|
Sebastian Meyer | d0dcdb5110 | |
Sebastian Meyer | 0bbeec44c9 | |
Sebastian Meyer | a2a0b721be | |
Sebastian Meyer | 83b73ff717 | |
Sebastian Meyer | 975785e989 | |
Sebastian Meyer | 05dc709e0a | |
Sebastian Meyer | ab68eb4792 |
|
@ -7,3 +7,4 @@ phpcs.xml
|
|||
phpdoc.xml
|
||||
phpstan.neon
|
||||
psalm.xml
|
||||
TODO
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
Changelog
|
||||
#########
|
||||
|
||||
.. contents::
|
||||
.. sidebar:: Table of Contents
|
||||
.. contents::
|
||||
|
||||
v2.0.0
|
||||
======
|
||||
|
@ -39,7 +40,9 @@ v2.0.0
|
|||
* Added new error handler :php:class:`OCC\Basics\ErrorHandlers\TriggerExceptionError`
|
||||
* Added new trait :php:trait:`OCC\Basics\Traits\OverloadingGetter`
|
||||
* Added new trait :php:trait:`OCC\Basics\Traits\OverloadingSetter`
|
||||
* Extended API for all datastructures
|
||||
* Added new trait :php:trait:`OCC\Basics\Traits\TypeChecker`
|
||||
* Extended API for all datastructures (see :php:trait:`OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait`)
|
||||
* Introduced :php:class:`OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException` for strict datastructures
|
||||
* Extended `documentation <https://opencultureconsulting.github.io/php-basics/>`_
|
||||
|
||||
v1.1.0
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
Documentation
|
||||
#############
|
||||
|
||||
.. meta::
|
||||
:layout: landingpage
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
:maxdepth: 2
|
||||
|
||||
overview/index
|
||||
usage/index
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
.. title:: Datastructures
|
||||
|
||||
Typed Datastructures
|
||||
####################
|
||||
|
||||
.. sidebar:: Table of Contents
|
||||
.. contents::
|
||||
|
||||
All datastructures in this package have in common that you can control the types of items they 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 `array`, `bool`, `callable`, `countable`,
|
||||
`float` / `double`, `int` / `integer` / `long`, `iterable`, `null`, `numeric`, `object`, `resource`, `scalar` and
|
||||
`string`.
|
||||
|
||||
Trying to add an item with a data type not on the list of allowed types to a strict datastructure will result in an
|
||||
:php:class:`OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException`.
|
||||
|
||||
Examples:
|
||||
|
||||
.. code-block:: php
|
||||
// create a collection of strings
|
||||
$stringCollection = new StrictCollection(['string']);
|
||||
|
||||
// create a queue of PSR-15 middlewares
|
||||
$middlewareQueue = new StrictQueue(['Psr\Http\Server\MiddlewareInterface']);
|
||||
|
||||
StrictCollection
|
||||
================
|
||||
|
||||
.. sidebar:: API Documentation
|
||||
:php:class:`OCC\Basics\DataStructures\StrictCollection`
|
||||
|
||||
*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.
|
||||
|
||||
A `StrictCollection` can be accessed like an array, but not traversed because it has no particular order. Technically
|
||||
speaking, `StrictCollection` implements `\ArrayAccess <https://www.php.net/arrayaccess>`_, `\Countable
|
||||
<https://www.php.net/countable>`_ and `\Serializable <https://www.php.net/serializable>`_, but no `\Traversable
|
||||
<https://www.php.net/traversable>`_ interface.
|
||||
|
||||
.. note::
|
||||
Internally it holds the items in the `$_data` array, the same as most :php:namespace:`OCC\Basics\Interfaces` and
|
||||
:php:namespace:`OCC\Basics\Traits` of this package.
|
||||
|
||||
StrictList
|
||||
==========
|
||||
|
||||
.. sidebar:: API Documentation
|
||||
:php:class:`OCC\Basics\DataStructures\StrictList`
|
||||
|
||||
*A type-sensitive, taversable list of items.*
|
||||
|
||||
Extends `\SplDoublyLinkedList <https://www.php.net/spldoublylinkedlist>`_ with an option to restrict the allowed data
|
||||
types for list items.
|
||||
|
||||
StrictQueue
|
||||
===========
|
||||
|
||||
.. sidebar:: API Documentation
|
||||
:php:class:`OCC\Basics\DataStructures\StrictQueue`
|
||||
|
||||
*A type-sensitive, taversable queue (FIFO) of items.*
|
||||
|
||||
Extends `\SplDoublyLinkedList <https://www.php.net/spldoublylinkedlist>`_ with an option to restrict the allowed data
|
||||
types for list items.
|
||||
|
||||
StrictStack
|
||||
===========
|
||||
|
||||
.. sidebar:: API Documentation
|
||||
:php:class:`OCC\Basics\DataStructures\StrictStack`
|
||||
|
||||
*A type-sensitive, taversable stack (LIFO) of items.*
|
||||
|
||||
Extends `\SplDoublyLinkedList <https://www.php.net/spldoublylinkedlist>`_ with an option to restrict the allowed data
|
||||
types for list items.
|
|
@ -0,0 +1,27 @@
|
|||
.. title:: Error Handlers
|
||||
|
||||
Error and Exception Handlers
|
||||
############################
|
||||
|
||||
.. sidebar:: Table of Contents
|
||||
.. contents::
|
||||
|
||||
ThrowErrorException
|
||||
===================
|
||||
|
||||
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.
|
||||
|
||||
> Usage: `set_error_handler(new ThrowErrorException());`
|
||||
|
||||
TriggerExceptionError
|
||||
=====================
|
||||
|
||||
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 `E_USER_ERROR`.
|
||||
|
||||
> Usage: `set_exception_handler(new TriggerExceptionError());`
|
|
@ -2,3 +2,17 @@
|
|||
|
||||
Overview
|
||||
########
|
||||
|
||||
The package currently contains classes for :doc:`datastructures`, :doc:`errorhandlers`, multiple :doc:`interfaces`, and
|
||||
more generic :doc:`traits` for common use cases. They share the same design principles like property and method naming
|
||||
schema, the highest coding standards of `PHPStan <https://phpstan.org/>`_ and `Psalm <https://psalm.dev/>`_, and full
|
||||
`PSR-12 <https://www.php-fig.org/psr/psr-12/>`_ compliance to make sure they can be combined and easily re-used in
|
||||
other projects.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
datastructures
|
||||
errorhandlers
|
||||
interfaces
|
||||
traits
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
.. title:: Interfaces
|
||||
|
||||
Interface Traits
|
||||
################
|
||||
|
||||
.. sidebar:: Table of Contents
|
||||
.. contents::
|
||||
|
||||
ArrayAccessTrait
|
||||
================
|
||||
|
||||
A generic implementation of the ArrayAccess interface.
|
||||
|
||||
Internally it accesses the protected `$_data` array.
|
||||
|
||||
CountableTrait
|
||||
==============
|
||||
|
||||
A generic implementation of the Countable interface.
|
||||
|
||||
Internally it counts the values of the protected `$_data` array.
|
||||
|
||||
IteratorAggregateTrait
|
||||
======================
|
||||
|
||||
A generic implementation of the IteratorAggregate interface.
|
||||
|
||||
Internally it iterates over the protected `$_data` array.
|
||||
|
||||
IteratorTrait
|
||||
=============
|
||||
|
||||
A generic implementation of the Iterator interface.
|
||||
|
||||
Internally it iterates over the protected `$_data` array.
|
|
@ -0,0 +1,78 @@
|
|||
.. title:: Traits
|
||||
|
||||
Traits
|
||||
######
|
||||
|
||||
.. sidebar:: Table of Contents
|
||||
.. contents::
|
||||
|
||||
Getter
|
||||
======
|
||||
|
||||
Reads data from inaccessible properties by using magic methods.
|
||||
|
||||
To make a `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).
|
||||
|
||||
> Example: If the property is named `$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.
|
||||
|
||||
OverloadingGetter
|
||||
=================
|
||||
|
||||
Overloads a class with readable magic properties.
|
||||
|
||||
Internally it reads the protected `$_data` array whose keys are interpreted
|
||||
as property names.
|
||||
|
||||
> Example: Reading `Foo->bar` will return the value of `$_data['bar']`.
|
||||
|
||||
OverloadingSetter
|
||||
=================
|
||||
|
||||
Overloads a class with writable magic properties.
|
||||
|
||||
Internally it writes the protected `$_data` array whose keys are interpreted
|
||||
as property names.
|
||||
|
||||
> Example: `Foo->bar = 42;` will set `$_data['bar']` to `42`.
|
||||
|
||||
Setter
|
||||
======
|
||||
|
||||
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
|
||||
first letter).
|
||||
|
||||
> Example: If the property is named `$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.
|
||||
|
||||
Singleton
|
||||
=========
|
||||
|
||||
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
|
||||
object (irrespective of the given arguments).
|
||||
|
||||
In order for this to work as expected, the constructor has to be implemented
|
||||
as `private` to prevent direct instantiation of the class.
|
||||
|
||||
TypeChecker
|
||||
===========
|
||||
|
||||
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.
|
|
@ -3,8 +3,12 @@
|
|||
User Guide
|
||||
##########
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
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 :doc:`../overview/index` page.
|
||||
|
||||
requirements
|
||||
installation
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
requirements
|
||||
installation
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
Installation
|
||||
############
|
||||
|
||||
.. sidebar:: Table of Contents
|
||||
.. contents::
|
||||
|
||||
Composer
|
||||
========
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ aside.phpdocumentor-sidebar
|
|||
padding: 0 var(--spacing-md) !important;
|
||||
}
|
||||
|
||||
p > code,
|
||||
li > code,
|
||||
code.prettyprint
|
||||
{
|
||||
background-color: var(--code-background-color);
|
||||
|
@ -50,6 +52,38 @@ code.prettyprint
|
|||
padding: var(--spacing-xxxs);
|
||||
}
|
||||
|
||||
@media (max-width: 999px) {
|
||||
div.admonition-wrapper
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1000px) {
|
||||
div.admonition-wrapper
|
||||
{
|
||||
display: block;
|
||||
float: right;
|
||||
padding: var(--spacing-md);
|
||||
margin: 0 0 var(--spacing-md) var(--spacing-md);
|
||||
width: auto;
|
||||
font-size: var(--text-sm);
|
||||
border: 1px solid var(--primary-color-lighten);
|
||||
}
|
||||
}
|
||||
|
||||
div.admonition-wrapper
|
||||
p.sidebar-title
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.contents
|
||||
ul.phpdocumentor-list
|
||||
{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.phpdocumentor-content
|
||||
div.section
|
||||
ul
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
<p class="phpdocumentor-summary">A collection of generic classes and useful traits for PHP projects.</p>
|
||||
|
||||
<p>The package currently contains classes for <a href="packages/Basics-DataStructures.html">type-sensitive
|
||||
data structures</a>, <a href="packages/Basics-ErrorHandlers.html">error and exception handlers</a>, multiple
|
||||
<a href="packages/Basics-Interfaces.html">traits implementing standard interfaces</a>, and more generic
|
||||
<a href="packages/Basics-Traits.html">traits for common use cases</a>. They share the same design principles
|
||||
<p>The package currently contains classes for <a href="guides/overview/datastructures.html">type-sensitive
|
||||
data structures</a>, <a href="guides/overview/errorhandlers.html">error and exception handlers</a>, multiple
|
||||
<a href="guides/overview/interfaces.html">traits implementing standard interfaces</a>, and more generic
|
||||
<a href="guides/overview/traits.html">traits for common use cases</a>. They share the same design principles
|
||||
like property and method naming schema, highest coding standards of <a href="https://phpstan.org/">PHPStan</a>
|
||||
and <a href="https://psalm.dev/">Psalm</a>, and full <a href="https://www.php-fig.org/psr/psr-12/">PSR-12</a>
|
||||
compliance to make sure they can be combined and easily re-used in other projects.</p>
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
"require-dev": {
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"phpstan/phpstan-strict-rules": "^1.5",
|
||||
"friendsofphp/php-cs-fixer": "^3.51",
|
||||
"friendsofphp/php-cs-fixer": "^3.52",
|
||||
"squizlabs/php_codesniffer": "^3.9",
|
||||
"vimeo/psalm": "^5.23"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,396 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<section>
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ.html">OCC</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ-basics.html">Basics</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ-basics-datastructures.html">DataStructures</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ-basics-datastructures-exceptions.html">Exceptions</a></li>
|
||||
</ul>
|
||||
|
||||
<article class="phpdocumentor-element -class">
|
||||
<h2 class="phpdocumentor-content__title">
|
||||
InvalidDataTypeException
|
||||
|
||||
<span class="phpdocumentor-element__extends">
|
||||
extends <abbr title="\DomainException">DomainException</abbr>
|
||||
</span>
|
||||
|
||||
<div class="phpdocumentor-element__package">
|
||||
in package
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
<li class="phpdocumentor-breadcrumb"><a href="packages/Basics.html">Basics</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="packages/Basics-DataStructures.html">DataStructures</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
</h2>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/Exceptions/InvalidDataTypeException.php"><a href="files/src-datastructures-exceptions-invaliddatatypeexception.html"><abbr title="src/DataStructures/Exceptions/InvalidDataTypeException.php">InvalidDataTypeException.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">37</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html#source-view.37" class="phpdocumentor-element-found-in__source" data-line="37" data-modal="source-view" data-src="files/src/DataStructures/Exceptions/InvalidDataTypeException.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Common exception for type-sensitive datastructures.</p>
|
||||
|
||||
<section class="phpdocumentor-description"><p>Exception thrown if a value does not adhere to the defined list of valid
|
||||
data types.</p>
|
||||
</section>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-tag-list__heading" id="tags">
|
||||
Tags
|
||||
<a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html#tags" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h5>
|
||||
<dl class="phpdocumentor-tag-list">
|
||||
<dt class="phpdocumentor-tag-list__entry">
|
||||
<span class="phpdocumentor-tag__name">author</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
|
||||
<section class="phpdocumentor-description"><p>Sebastian Meyer <a href="mailto:sebastian.meyer@opencultureconsulting.com">sebastian.meyer@opencultureconsulting.com</a></p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<h3 id="toc">
|
||||
Table of Contents
|
||||
<a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html#toc" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="phpdocumentor-modal" id="source-view">
|
||||
<div class="phpdocumentor-modal-bg" data-exit-button></div>
|
||||
<div class="phpdocumentor-modal-container">
|
||||
<div class="phpdocumentor-modal-content">
|
||||
<pre style="max-height: 500px; overflow-y: scroll" data-src="files/src/DataStructures/Exceptions/InvalidDataTypeException.php.txt" class="language-php line-numbers linkable-line-numbers"></pre>
|
||||
</div>
|
||||
<button data-exit-button class="phpdocumentor-modal__close">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
function loadExternalCodeSnippet(el, url, line) {
|
||||
Array.prototype.slice.call(el.querySelectorAll('pre[data-src]')).forEach((pre) => {
|
||||
const src = url || pre.getAttribute('data-src').replace(/\\/g, '/');
|
||||
const language = 'php';
|
||||
|
||||
const code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
pre.textContent = '';
|
||||
pre.setAttribute('data-line', line)
|
||||
code.textContent = 'Loading…';
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
Prism.highlightElement(code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status === 404) {
|
||||
code.textContent = '✖ Error: File could not be found';
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
return;
|
||||
}
|
||||
|
||||
code.textContent = '✖ Error: An unknown error occurred';
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
const modalButtons = document.querySelectorAll("[data-modal]");
|
||||
const openedAsLocalFile = window.location.protocol === 'file:';
|
||||
if (modalButtons.length > 0 && openedAsLocalFile) {
|
||||
console.warn(
|
||||
'Viewing the source code is unavailable because you are opening this page from the file:// scheme; ' +
|
||||
'browsers block XHR requests when a page is opened this way'
|
||||
);
|
||||
}
|
||||
|
||||
modalButtons.forEach(function (trigger) {
|
||||
if (openedAsLocalFile) {
|
||||
trigger.setAttribute("hidden", "hidden");
|
||||
}
|
||||
|
||||
trigger.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
const modal = document.getElementById(trigger.dataset.modal);
|
||||
if (!modal) {
|
||||
console.error(`Modal with id "${trigger.dataset.modal}" could not be found`);
|
||||
return;
|
||||
}
|
||||
modal.classList.add("phpdocumentor-modal__open");
|
||||
|
||||
loadExternalCodeSnippet(modal, trigger.dataset.src || null, trigger.dataset.line)
|
||||
const exits = modal.querySelectorAll("[data-exit-button]");
|
||||
exits.forEach(function (exit) {
|
||||
exit.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
modal.classList.remove("phpdocumentor-modal__open");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
</article>
|
||||
</section>
|
||||
<section class="phpdocumentor-on-this-page__sidebar">
|
||||
|
||||
<section class="phpdocumentor-on-this-page__content">
|
||||
<strong class="phpdocumentor-on-this-page__title">On this page</strong>
|
||||
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li class="phpdocumentor-on-this-page-section__title">Table Of Contents</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -175,7 +193,7 @@
|
|||
|
||||
<span class="phpdocumentor-element__extends">
|
||||
Uses
|
||||
<a href="classes/OCC-Basics-Interfaces-ArrayAccessTrait.html"><abbr title="\OCC\Basics\Interfaces\ArrayAccessTrait">ArrayAccessTrait</abbr></a>, <a href="classes/OCC-Basics-Interfaces-CountableTrait.html"><abbr title="\OCC\Basics\Interfaces\CountableTrait">CountableTrait</abbr></a>, <a href="classes/OCC-Basics-Traits-Getter.html"><abbr title="\OCC\Basics\Traits\Getter">Getter</abbr></a> </span>
|
||||
<a href="classes/OCC-Basics-Interfaces-ArrayAccessTrait.html"><abbr title="\OCC\Basics\Interfaces\ArrayAccessTrait">ArrayAccessTrait</abbr></a>, <a href="classes/OCC-Basics-Interfaces-CountableTrait.html"><abbr title="\OCC\Basics\Interfaces\CountableTrait">CountableTrait</abbr></a>, <a href="classes/OCC-Basics-Traits-TypeChecker.html"><abbr title="\OCC\Basics\Traits\TypeChecker">TypeChecker</abbr></a> </span>
|
||||
</h2>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
|
@ -186,9 +204,9 @@
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">83</span>
|
||||
<span class="phpdocumentor-element-found-in__line">63</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.83" class="phpdocumentor-element-found-in__source" data-line="83" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.63" class="phpdocumentor-element-found-in__source" data-line="63" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">A type-sensitive, unsorted collection.</p>
|
||||
|
@ -250,19 +268,6 @@ names.</p>
|
|||
|
||||
|
||||
|
||||
<h4 id="toc-properties">
|
||||
Properties
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#toc-properties" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -property -public">
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#property_allowedTypes">$allowedTypes</a>
|
||||
<span>
|
||||
: array<string|int, string> </span>
|
||||
</dt>
|
||||
|
||||
</dl>
|
||||
|
||||
<h4 id="toc-methods">
|
||||
Methods
|
||||
|
@ -277,26 +282,12 @@ names.</p>
|
|||
</dt>
|
||||
<dd>Create a type-sensitive collection of items.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-Traits-Getter.html#method___get">__get()</a>
|
||||
<span>
|
||||
: mixed </span>
|
||||
</dt>
|
||||
<dd>Read data from an inaccessible property.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-Traits-Getter.html#method___isset">__isset()</a>
|
||||
<span>
|
||||
: bool </span>
|
||||
</dt>
|
||||
<dd>Check if an inaccessible property is set and not empty.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_add">add()</a>
|
||||
<span>
|
||||
: void </span>
|
||||
</dt>
|
||||
<dd>Add/insert a new item at the specified index.</dd>
|
||||
<dd>Add/insert a item at the specified index.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_clear">clear()</a>
|
||||
|
@ -315,23 +306,30 @@ names.</p>
|
|||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_get">get()</a>
|
||||
<span>
|
||||
: <abbr title="\OCC\Basics\DataStructures\AllowedType">AllowedType</abbr>|null </span>
|
||||
: <abbr title="\OCC\Basics\DataStructures\AllowedType">AllowedType</abbr> </span>
|
||||
</dt>
|
||||
<dd>Get the item at the specified index.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_getAllowedTypes">getAllowedTypes()</a>
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_getAllowedTypes">getAllowedTypes()</a>
|
||||
<span>
|
||||
: array<string|int, string> </span>
|
||||
</dt>
|
||||
<dd>Get allowed data types for collection items.</dd>
|
||||
<dd>Get allowed data types.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_isAllowedType">isAllowedType()</a>
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_hasAllowedType">hasAllowedType()</a>
|
||||
<span>
|
||||
: bool </span>
|
||||
</dt>
|
||||
<dd>Check if the item's data type is allowed in the collection.</dd>
|
||||
<dd>Check if a value's data type is allowed.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_isAllowedType">isAllowedType()</a>
|
||||
<span>
|
||||
: bool </span>
|
||||
</dt>
|
||||
<dd>Check if a data type is allowed.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_isEmpty">isEmpty()</a>
|
||||
|
@ -396,6 +394,13 @@ names.</p>
|
|||
</dt>
|
||||
<dd>Set an item at the specified index.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_setAllowedTypes">setAllowedTypes()</a>
|
||||
<span>
|
||||
: void </span>
|
||||
</dt>
|
||||
<dd>Set allowed data types.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_toArray">toArray()</a>
|
||||
<span>
|
||||
|
@ -417,13 +422,6 @@ names.</p>
|
|||
</dt>
|
||||
<dd>Restore $this from string representation.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -protected">
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_setAllowedTypes">setAllowedTypes()</a>
|
||||
<span>
|
||||
: void </span>
|
||||
</dt>
|
||||
<dd>Set allowed data types of collection items.</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
@ -432,49 +430,6 @@ names.</p>
|
|||
|
||||
|
||||
|
||||
<section class="phpdocumentor-properties">
|
||||
<h3 class="phpdocumentor-elements__header" id="properties">
|
||||
Properties
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#properties" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
<article
|
||||
class="
|
||||
phpdocumentor-element
|
||||
-property
|
||||
-public
|
||||
-read-only "
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="property_allowedTypes">
|
||||
$allowedTypes
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#property_allowedTypes" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
<span class="phpdocumentor-element__modifiers">
|
||||
<small class="phpdocumentor-element__modifier">read-only</small> </span>
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">0</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.0" class="phpdocumentor-element-found-in__source" data-line="0" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__type">array<string|int, string></span>
|
||||
<span class="phpdocumentor-signature__name">$allowedTypes</span>
|
||||
</code>
|
||||
|
||||
<section class="phpdocumentor-description"><p>The allowed data types for items.</p>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-methods">
|
||||
<h3 class="phpdocumentor-elements__header" id="methods">
|
||||
|
@ -496,9 +451,9 @@ names.</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">401</span>
|
||||
<span class="phpdocumentor-element-found-in__line">325</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.401" class="phpdocumentor-element-found-in__source" data-line="401" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.325" class="phpdocumentor-element-found-in__source" data-line="325" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Create a type-sensitive collection of items.</p>
|
||||
|
@ -560,129 +515,6 @@ Possible values are:</p>
|
|||
</dl>
|
||||
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-public
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method___get">
|
||||
__get()
|
||||
<a href="classes/OCC-Basics-Traits-Getter.html#method___get" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/Traits/Getter.php"><a href="files/src-traits-getter.html"><abbr title="src/Traits/Getter.php">Getter.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">60</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.60" class="phpdocumentor-element-found-in__source" data-line="60" data-modal="source-view" data-src="files/src/Traits/Getter.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Read data from an inaccessible property.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__name">__get</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string </span><span class="phpdocumentor-signature__argument__name">$property</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">mixed</span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
</div>
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$property</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type">string</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The class property to get</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-tag-list__heading" id="tags">
|
||||
Tags
|
||||
<a href="classes/OCC-Basics-Traits-Getter.html#method___get#tags" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h5>
|
||||
<dl class="phpdocumentor-tag-list">
|
||||
<dt class="phpdocumentor-tag-list__entry">
|
||||
<span class="phpdocumentor-tag__name">throws</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
<span class="phpdocumentor-tag-link"><abbr title="\InvalidArgumentException">InvalidArgumentException</abbr></span>
|
||||
|
||||
<section class="phpdocumentor-description"><p>if the property or getter method do not exist</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<section>
|
||||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type">mixed</span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>The class property's current value</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-public
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method___isset">
|
||||
__isset()
|
||||
<a href="classes/OCC-Basics-Traits-Getter.html#method___isset" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/Traits/Getter.php"><a href="files/src-traits-getter.html"><abbr title="src/Traits/Getter.php">Getter.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">83</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.83" class="phpdocumentor-element-found-in__source" data-line="83" data-modal="source-view" data-src="files/src/Traits/Getter.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Check if an inaccessible property is set and not empty.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__name">__isset</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string </span><span class="phpdocumentor-signature__argument__name">$property</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">bool</span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
</div>
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$property</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type">string</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The class property to check</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type">bool</span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>Whether the class property is set and not empty</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
|
@ -698,12 +530,12 @@ Possible values are:</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">121</span>
|
||||
<span class="phpdocumentor-element-found-in__line">94</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.121" class="phpdocumentor-element-found-in__source" data-line="121" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.94" class="phpdocumentor-element-found-in__source" data-line="94" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Add/insert a new item at the specified index.</p>
|
||||
<p class="phpdocumentor-summary">Add/insert a item at the specified index.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
|
@ -721,7 +553,7 @@ Possible values are:</p>
|
|||
: <span class="phpdocumentor-signature__argument__return-type">string|int</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The new item's index</p>
|
||||
<section class="phpdocumentor-description"><p>The item's index</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
|
@ -730,7 +562,7 @@ Possible values are:</p>
|
|||
: <span class="phpdocumentor-signature__argument__return-type"><abbr title="\OCC\Basics\DataStructures\AllowedType">AllowedType</abbr></span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The new item</p>
|
||||
<section class="phpdocumentor-description"><p>The item</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
|
@ -747,9 +579,9 @@ Possible values are:</p>
|
|||
<span class="phpdocumentor-tag__name">throws</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
<span class="phpdocumentor-tag-link"><abbr title="\InvalidArgumentException">InvalidArgumentException</abbr></span>
|
||||
<span class="phpdocumentor-tag-link"><a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html"><abbr title="\OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException">InvalidDataTypeException</abbr></a></span>
|
||||
|
||||
<section class="phpdocumentor-description"><p>if <code class="prettyprint">$offset</code> is not of allowed type</p>
|
||||
<section class="phpdocumentor-description"><p>if <code class="prettyprint">$value</code> is not of allowed type</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
|
@ -771,9 +603,9 @@ Possible values are:</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">133</span>
|
||||
<span class="phpdocumentor-element-found-in__line">106</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.133" class="phpdocumentor-element-found-in__source" data-line="133" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.106" class="phpdocumentor-element-found-in__source" data-line="106" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Clear the collection of any items.</p>
|
||||
|
@ -849,16 +681,16 @@ Possible values are:</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">147</span>
|
||||
<span class="phpdocumentor-element-found-in__line">122</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.147" class="phpdocumentor-element-found-in__source" data-line="147" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.122" class="phpdocumentor-element-found-in__source" data-line="122" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Get the item at the specified index.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__name">get</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string|int </span><span class="phpdocumentor-signature__argument__name">$offset</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type"><abbr title="\OCC\Basics\DataStructures\AllowedType">AllowedType</abbr>|null</span></code>
|
||||
<span class="phpdocumentor-signature__name">get</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string|int </span><span class="phpdocumentor-signature__argument__name">$offset</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type"><abbr title="\OCC\Basics\DataStructures\AllowedType">AllowedType</abbr></span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
<div class="phpdocumentor-label phpdocumentor-label--success"><span>API</span><span>Yes</span></div>
|
||||
|
@ -879,12 +711,29 @@ Possible values are:</p>
|
|||
</dl>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-tag-list__heading" id="tags">
|
||||
Tags
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_get#tags" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h5>
|
||||
<dl class="phpdocumentor-tag-list">
|
||||
<dt class="phpdocumentor-tag-list__entry">
|
||||
<span class="phpdocumentor-tag__name">throws</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
<span class="phpdocumentor-tag-link"><abbr title="\OutOfRangeException">OutOfRangeException</abbr></span>
|
||||
|
||||
<section class="phpdocumentor-description"><p>when <code class="prettyprint">$offset</code> is out of bounds</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<section>
|
||||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type"><abbr title="\OCC\Basics\DataStructures\AllowedType">AllowedType</abbr>|null</span>
|
||||
<span class="phpdocumentor-signature__response_type"><abbr title="\OCC\Basics\DataStructures\AllowedType">AllowedType</abbr></span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>The item or NULL if key is invalid</p>
|
||||
<section class="phpdocumentor-description"><p>The item</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
@ -898,18 +747,18 @@ Possible values are:</p>
|
|||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_getAllowedTypes">
|
||||
getAllowedTypes()
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_getAllowedTypes" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_getAllowedTypes" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/Traits/TypeChecker.php"><a href="files/src-traits-typechecker.html"><abbr title="src/Traits/TypeChecker.php">TypeChecker.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">159</span>
|
||||
<span class="phpdocumentor-element-found-in__line">83</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.159" class="phpdocumentor-element-found-in__source" data-line="159" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.83" class="phpdocumentor-element-found-in__source" data-line="83" data-modal="source-view" data-src="files/src/Traits/TypeChecker.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Get allowed data types for collection items.</p>
|
||||
<p class="phpdocumentor-summary">Get allowed data types.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
|
@ -939,24 +788,24 @@ Possible values are:</p>
|
|||
-public
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_isAllowedType">
|
||||
isAllowedType()
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_isAllowedType" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
<h4 class="phpdocumentor-element__name" id="method_hasAllowedType">
|
||||
hasAllowedType()
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_hasAllowedType" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/Traits/TypeChecker.php"><a href="files/src-traits-typechecker.html"><abbr title="src/Traits/TypeChecker.php">TypeChecker.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">173</span>
|
||||
<span class="phpdocumentor-element-found-in__line">97</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.173" class="phpdocumentor-element-found-in__source" data-line="173" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.97" class="phpdocumentor-element-found-in__source" data-line="97" data-modal="source-view" data-src="files/src/Traits/TypeChecker.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Check if the item's data type is allowed in the collection.</p>
|
||||
<p class="phpdocumentor-summary">Check if a value's data type is allowed.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__name">isAllowedType</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><abbr title="\OCC\Basics\DataStructures\AllowedType">AllowedType</abbr> </span><span class="phpdocumentor-signature__argument__name">$value</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">bool</span></code>
|
||||
<span class="phpdocumentor-signature__name">hasAllowedType</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">mixed </span><span class="phpdocumentor-signature__argument__name">$value</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">bool</span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
<div class="phpdocumentor-label phpdocumentor-label--success"><span>API</span><span>Yes</span></div>
|
||||
|
@ -967,10 +816,10 @@ Possible values are:</p>
|
|||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$value</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type"><abbr title="\OCC\Basics\DataStructures\AllowedType">AllowedType</abbr></span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type">mixed</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The item to check</p>
|
||||
<section class="phpdocumentor-description"><p>The value to check</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
|
@ -982,7 +831,62 @@ Possible values are:</p>
|
|||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type">bool</span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>Whether the item's data type is allowed</p>
|
||||
<section class="phpdocumentor-description"><p>Whether the value's data type is allowed</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-public
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_isAllowedType">
|
||||
isAllowedType()
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_isAllowedType" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/Traits/TypeChecker.php"><a href="files/src-traits-typechecker.html"><abbr title="src/Traits/TypeChecker.php">TypeChecker.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">125</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.125" class="phpdocumentor-element-found-in__source" data-line="125" data-modal="source-view" data-src="files/src/Traits/TypeChecker.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Check if a data type is allowed.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__name">isAllowedType</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string </span><span class="phpdocumentor-signature__argument__name">$type</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">bool</span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
<div class="phpdocumentor-label phpdocumentor-label--success"><span>API</span><span>Yes</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$type</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type">string</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The type to check</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type">bool</span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>Whether the data type is allowed</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
@ -1002,9 +906,9 @@ Possible values are:</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">199</span>
|
||||
<span class="phpdocumentor-element-found-in__line">144</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.199" class="phpdocumentor-element-found-in__source" data-line="199" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.144" class="phpdocumentor-element-found-in__source" data-line="144" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Check if collection is empty.</p>
|
||||
|
@ -1045,9 +949,9 @@ Possible values are:</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">216</span>
|
||||
<span class="phpdocumentor-element-found-in__line">161</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.216" class="phpdocumentor-element-found-in__source" data-line="216" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.161" class="phpdocumentor-element-found-in__source" data-line="161" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Check if this collection can be considered a list.</p>
|
||||
|
@ -1216,9 +1120,9 @@ from <code class="prettyprint">0</code>.</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">233</span>
|
||||
<span class="phpdocumentor-element-found-in__line">179</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.233" class="phpdocumentor-element-found-in__source" data-line="233" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.179" class="phpdocumentor-element-found-in__source" data-line="179" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Set the item at the specified offset.</p>
|
||||
|
@ -1264,10 +1168,20 @@ from <code class="prettyprint">0</code>.</p>
|
|||
<dt class="phpdocumentor-tag-list__entry">
|
||||
<span class="phpdocumentor-tag__name">throws</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
<span class="phpdocumentor-tag-link"><a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html"><abbr title="\OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException">InvalidDataTypeException</abbr></a></span>
|
||||
|
||||
<section class="phpdocumentor-description"><p>if <code class="prettyprint">$value</code> is not of allowed type</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
<dt class="phpdocumentor-tag-list__entry">
|
||||
<span class="phpdocumentor-tag__name">throws</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
<span class="phpdocumentor-tag-link"><abbr title="\InvalidArgumentException">InvalidArgumentException</abbr></span>
|
||||
|
||||
<section class="phpdocumentor-description"><p>if <code class="prettyprint">$offset</code> or <code class="prettyprint">$value</code> is not of allowed type</p>
|
||||
<section class="phpdocumentor-description"><p>if <code class="prettyprint">$offset</code> is not a valid array key</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
|
@ -1336,9 +1250,9 @@ from <code class="prettyprint">0</code>.</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">263</span>
|
||||
<span class="phpdocumentor-element-found-in__line">211</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.263" class="phpdocumentor-element-found-in__source" data-line="263" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.211" class="phpdocumentor-element-found-in__source" data-line="211" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Remove an item from the collection.</p>
|
||||
|
@ -1366,6 +1280,23 @@ from <code class="prettyprint">0</code>.</p>
|
|||
</dl>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-tag-list__heading" id="tags">
|
||||
Tags
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_remove#tags" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h5>
|
||||
<dl class="phpdocumentor-tag-list">
|
||||
<dt class="phpdocumentor-tag-list__entry">
|
||||
<span class="phpdocumentor-tag__name">throws</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
<span class="phpdocumentor-tag-link"><abbr title="\OutOfRangeException">OutOfRangeException</abbr></span>
|
||||
|
||||
<section class="phpdocumentor-description"><p>when <code class="prettyprint">$offset</code> is out of bounds</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</article>
|
||||
|
@ -1383,9 +1314,9 @@ from <code class="prettyprint">0</code>.</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">273</span>
|
||||
<span class="phpdocumentor-element-found-in__line">229</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.273" class="phpdocumentor-element-found-in__source" data-line="273" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.229" class="phpdocumentor-element-found-in__source" data-line="229" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Get string representation of $this.</p>
|
||||
|
@ -1424,9 +1355,9 @@ from <code class="prettyprint">0</code>.</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">290</span>
|
||||
<span class="phpdocumentor-element-found-in__line">246</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.290" class="phpdocumentor-element-found-in__source" data-line="290" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.246" class="phpdocumentor-element-found-in__source" data-line="246" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Set an item at the specified index.</p>
|
||||
|
@ -1473,7 +1404,7 @@ from <code class="prettyprint">0</code>.</p>
|
|||
<span class="phpdocumentor-tag__name">throws</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
<span class="phpdocumentor-tag-link"><abbr title="\InvalidArgumentException">InvalidArgumentException</abbr></span>
|
||||
<span class="phpdocumentor-tag-link"><a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html"><abbr title="\OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException">InvalidDataTypeException</abbr></a></span>
|
||||
|
||||
<section class="phpdocumentor-description"><p>if <code class="prettyprint">$value</code> is not of allowed type</p>
|
||||
</section>
|
||||
|
@ -1482,6 +1413,70 @@ from <code class="prettyprint">0</code>.</p>
|
|||
</dl>
|
||||
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-public
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_setAllowedTypes">
|
||||
setAllowedTypes()
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_setAllowedTypes" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/Traits/TypeChecker.php"><a href="files/src-traits-typechecker.html"><abbr title="src/Traits/TypeChecker.php">TypeChecker.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">141</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.141" class="phpdocumentor-element-found-in__source" data-line="141" data-modal="source-view" data-src="files/src/Traits/TypeChecker.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Set allowed data types.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__name">setAllowedTypes</span><span>(</span><span class="phpdocumentor-signature__argument"><span>[</span><span class="phpdocumentor-signature__argument__return-type">array<string|int, string> </span><span class="phpdocumentor-signature__argument__name">$allowedTypes</span><span> = </span><span class="phpdocumentor-signature__argument__default-value">[]</span><span> ]</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">void</span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
<div class="phpdocumentor-label phpdocumentor-label--success"><span>API</span><span>Yes</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$allowedTypes</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type">array<string|int, string></span>
|
||||
= <span class="phpdocumentor-signature__argument__default-value">[]</span> </dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>Allowed data types</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-tag-list__heading" id="tags">
|
||||
Tags
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_setAllowedTypes#tags" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h5>
|
||||
<dl class="phpdocumentor-tag-list">
|
||||
<dt class="phpdocumentor-tag-list__entry">
|
||||
<span class="phpdocumentor-tag__name">throws</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
<span class="phpdocumentor-tag-link"><abbr title="\InvalidArgumentException">InvalidArgumentException</abbr></span>
|
||||
|
||||
<section class="phpdocumentor-description"><p>if any value of <code class="prettyprint">$allowedTypes</code> is not a string</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
|
@ -1497,9 +1492,9 @@ from <code class="prettyprint">0</code>.</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">321</span>
|
||||
<span class="phpdocumentor-element-found-in__line">258</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.321" class="phpdocumentor-element-found-in__source" data-line="321" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.258" class="phpdocumentor-element-found-in__source" data-line="258" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Return array representation of collection.</p>
|
||||
|
@ -1540,9 +1535,9 @@ from <code class="prettyprint">0</code>.</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">337</span>
|
||||
<span class="phpdocumentor-element-found-in__line">274</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.337" class="phpdocumentor-element-found-in__source" data-line="337" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.274" class="phpdocumentor-element-found-in__source" data-line="274" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Turn collection into a type-sensitive list.</p>
|
||||
|
@ -1608,9 +1603,9 @@ from <code class="prettyprint">0</code>.</p>
|
|||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">357</span>
|
||||
<span class="phpdocumentor-element-found-in__line">293</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.357" class="phpdocumentor-element-found-in__source" data-line="357" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.293" class="phpdocumentor-element-found-in__source" data-line="293" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Restore $this from string representation.</p>
|
||||
|
@ -1638,68 +1633,6 @@ from <code class="prettyprint">0</code>.</p>
|
|||
|
||||
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-protected
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_setAllowedTypes">
|
||||
setAllowedTypes()
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_setAllowedTypes" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/DataStructures/StrictCollection.php"><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">304</span>
|
||||
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#source-view.304" class="phpdocumentor-element-found-in__source" data-line="304" data-modal="source-view" data-src="files/src/DataStructures/StrictCollection.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Set allowed data types of collection items.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">protected</span>
|
||||
<span class="phpdocumentor-signature__name">setAllowedTypes</span><span>(</span><span class="phpdocumentor-signature__argument"><span>[</span><span class="phpdocumentor-signature__argument__return-type">array<string|int, string> </span><span class="phpdocumentor-signature__argument__name">$allowedTypes</span><span> = </span><span class="phpdocumentor-signature__argument__default-value">[]</span><span> ]</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">void</span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
</div>
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$allowedTypes</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type">array<string|int, string></span>
|
||||
= <span class="phpdocumentor-signature__argument__default-value">[]</span> </dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>Allowed data types of items</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-tag-list__heading" id="tags">
|
||||
Tags
|
||||
<a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_setAllowedTypes#tags" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h5>
|
||||
<dl class="phpdocumentor-tag-list">
|
||||
<dt class="phpdocumentor-tag-list__entry">
|
||||
<span class="phpdocumentor-tag__name">throws</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
<span class="phpdocumentor-tag-link"><abbr title="\InvalidArgumentException">InvalidArgumentException</abbr></span>
|
||||
|
||||
<section class="phpdocumentor-description"><p>if any value of <code class="prettyprint">$allowedTypes</code> is not a string</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
@ -1806,30 +1739,22 @@ from <code class="prettyprint">0</code>.</p>
|
|||
<li class="phpdocumentor-on-this-page-section__title">Table Of Contents</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#toc-properties">Properties</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#toc-methods">Methods</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#toc-methods">Methods</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="phpdocumentor-on-this-page-section__title">Properties</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#property_allowedTypes">$allowedTypes<a href="classes/OCC-Basics-DataStructures-StrictCollection.html"></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="phpdocumentor-on-this-page-section__title">Methods</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method___construct">__construct()</a></li>
|
||||
<li><a href="classes/OCC-Basics-Traits-Getter.html#method___get">__get()</a></li>
|
||||
<li><a href="classes/OCC-Basics-Traits-Getter.html#method___isset">__isset()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_add">add()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_clear">clear()</a></li>
|
||||
<li><a href="classes/OCC-Basics-Interfaces-CountableTrait.html#method_count">count()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_get">get()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_getAllowedTypes">getAllowedTypes()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_isAllowedType">isAllowedType()</a></li>
|
||||
<li><a href="classes/OCC-Basics-Traits-TypeChecker.html#method_getAllowedTypes">getAllowedTypes()</a></li>
|
||||
<li><a href="classes/OCC-Basics-Traits-TypeChecker.html#method_hasAllowedType">hasAllowedType()</a></li>
|
||||
<li><a href="classes/OCC-Basics-Traits-TypeChecker.html#method_isAllowedType">isAllowedType()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_isEmpty">isEmpty()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_isList">isList()</a></li>
|
||||
<li><a href="classes/OCC-Basics-Interfaces-ArrayAccessTrait.html#method_offsetExists">offsetExists()</a></li>
|
||||
|
@ -1839,10 +1764,10 @@ from <code class="prettyprint">0</code>.</p>
|
|||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_remove">remove()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_serialize">serialize()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_set">set()</a></li>
|
||||
<li><a href="classes/OCC-Basics-Traits-TypeChecker.html#method_setAllowedTypes">setAllowedTypes()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_toArray">toArray()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_toStrictList">toStrictList()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_unserialize">unserialize()</a></li>
|
||||
<li><a href="classes/OCC-Basics-DataStructures-StrictCollection.html#method_setAllowedTypes">setAllowedTypes()</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -0,0 +1,644 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<section>
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ.html">OCC</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ-basics.html">Basics</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ-basics-traits.html">Traits</a></li>
|
||||
</ul>
|
||||
|
||||
<article class="phpdocumentor-element -trait">
|
||||
<h2 class="phpdocumentor-content__title">
|
||||
TypeChecker
|
||||
</h2>
|
||||
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/Traits/TypeChecker.php"><a href="files/src-traits-typechecker.html"><abbr title="src/Traits/TypeChecker.php">TypeChecker.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">65</span>
|
||||
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#source-view.65" class="phpdocumentor-element-found-in__source" data-line="65" data-modal="source-view" data-src="files/src/Traits/TypeChecker.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">A generic data type checker.</p>
|
||||
|
||||
<section class="phpdocumentor-description"><p>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.</p>
|
||||
</section>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-tag-list__heading" id="tags">
|
||||
Tags
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#tags" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h5>
|
||||
<dl class="phpdocumentor-tag-list">
|
||||
<dt class="phpdocumentor-tag-list__entry">
|
||||
<span class="phpdocumentor-tag__name">author</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
|
||||
<section class="phpdocumentor-description"><p>Sebastian Meyer <a href="mailto:sebastian.meyer@opencultureconsulting.com">sebastian.meyer@opencultureconsulting.com</a></p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<h3 id="toc">
|
||||
Table of Contents
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#toc" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 id="toc-methods">
|
||||
Methods
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#toc-methods" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_getAllowedTypes">getAllowedTypes()</a>
|
||||
<span>
|
||||
: array<string|int, string> </span>
|
||||
</dt>
|
||||
<dd>Get allowed data types.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_hasAllowedType">hasAllowedType()</a>
|
||||
<span>
|
||||
: bool </span>
|
||||
</dt>
|
||||
<dd>Check if a value's data type is allowed.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_isAllowedType">isAllowedType()</a>
|
||||
<span>
|
||||
: bool </span>
|
||||
</dt>
|
||||
<dd>Check if a data type is allowed.</dd>
|
||||
|
||||
<dt class="phpdocumentor-table-of-contents__entry -method -public">
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_setAllowedTypes">setAllowedTypes()</a>
|
||||
<span>
|
||||
: void </span>
|
||||
</dt>
|
||||
<dd>Set allowed data types.</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section class="phpdocumentor-methods">
|
||||
<h3 class="phpdocumentor-elements__header" id="methods">
|
||||
Methods
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#methods" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-public
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_getAllowedTypes">
|
||||
getAllowedTypes()
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_getAllowedTypes" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/Traits/TypeChecker.php"><a href="files/src-traits-typechecker.html"><abbr title="src/Traits/TypeChecker.php">TypeChecker.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">83</span>
|
||||
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#source-view.83" class="phpdocumentor-element-found-in__source" data-line="83" data-modal="source-view" data-src="files/src/Traits/TypeChecker.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Get allowed data types.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__name">getAllowedTypes</span><span>(</span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">array<string|int, string></span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
<div class="phpdocumentor-label phpdocumentor-label--success"><span>API</span><span>Yes</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type">array<string|int, string></span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>The list of allowed data types</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-public
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_hasAllowedType">
|
||||
hasAllowedType()
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_hasAllowedType" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/Traits/TypeChecker.php"><a href="files/src-traits-typechecker.html"><abbr title="src/Traits/TypeChecker.php">TypeChecker.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">97</span>
|
||||
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#source-view.97" class="phpdocumentor-element-found-in__source" data-line="97" data-modal="source-view" data-src="files/src/Traits/TypeChecker.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Check if a value's data type is allowed.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__name">hasAllowedType</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">mixed </span><span class="phpdocumentor-signature__argument__name">$value</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">bool</span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
<div class="phpdocumentor-label phpdocumentor-label--success"><span>API</span><span>Yes</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$value</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type">mixed</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The value to check</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type">bool</span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>Whether the value's data type is allowed</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-public
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_isAllowedType">
|
||||
isAllowedType()
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_isAllowedType" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/Traits/TypeChecker.php"><a href="files/src-traits-typechecker.html"><abbr title="src/Traits/TypeChecker.php">TypeChecker.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">125</span>
|
||||
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#source-view.125" class="phpdocumentor-element-found-in__source" data-line="125" data-modal="source-view" data-src="files/src/Traits/TypeChecker.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Check if a data type is allowed.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__name">isAllowedType</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string </span><span class="phpdocumentor-signature__argument__name">$type</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">bool</span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
<div class="phpdocumentor-label phpdocumentor-label--success"><span>API</span><span>Yes</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$type</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type">string</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>The type to check</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h5 class="phpdocumentor-return-value__heading">Return values</h5>
|
||||
<span class="phpdocumentor-signature__response_type">bool</span>
|
||||
—
|
||||
<section class="phpdocumentor-description"><p>Whether the data type is allowed</p>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</article>
|
||||
<article
|
||||
class="phpdocumentor-element
|
||||
-method
|
||||
-public
|
||||
"
|
||||
>
|
||||
<h4 class="phpdocumentor-element__name" id="method_setAllowedTypes">
|
||||
setAllowedTypes()
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_setAllowedTypes" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<aside class="phpdocumentor-element-found-in">
|
||||
<abbr class="phpdocumentor-element-found-in__file" title="src/Traits/TypeChecker.php"><a href="files/src-traits-typechecker.html"><abbr title="src/Traits/TypeChecker.php">TypeChecker.php</abbr></a></abbr>
|
||||
:
|
||||
<span class="phpdocumentor-element-found-in__line">141</span>
|
||||
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#source-view.141" class="phpdocumentor-element-found-in__source" data-line="141" data-modal="source-view" data-src="files/src/Traits/TypeChecker.php.txt"></a>
|
||||
</aside>
|
||||
|
||||
<p class="phpdocumentor-summary">Set allowed data types.</p>
|
||||
|
||||
<code class="phpdocumentor-code phpdocumentor-signature ">
|
||||
<span class="phpdocumentor-signature__visibility">public</span>
|
||||
<span class="phpdocumentor-signature__name">setAllowedTypes</span><span>(</span><span class="phpdocumentor-signature__argument"><span>[</span><span class="phpdocumentor-signature__argument__return-type">array<string|int, string> </span><span class="phpdocumentor-signature__argument__name">$allowedTypes</span><span> = </span><span class="phpdocumentor-signature__argument__default-value">[]</span><span> ]</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">void</span></code>
|
||||
|
||||
<div class="phpdocumentor-label-line">
|
||||
<div class="phpdocumentor-label phpdocumentor-label--success"><span>API</span><span>Yes</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
<h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
|
||||
<dl class="phpdocumentor-argument-list">
|
||||
<dt class="phpdocumentor-argument-list__entry">
|
||||
<span class="phpdocumentor-signature__argument__name">$allowedTypes</span>
|
||||
: <span class="phpdocumentor-signature__argument__return-type">array<string|int, string></span>
|
||||
= <span class="phpdocumentor-signature__argument__default-value">[]</span> </dt>
|
||||
<dd class="phpdocumentor-argument-list__definition">
|
||||
<section class="phpdocumentor-description"><p>Allowed data types</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<h5 class="phpdocumentor-tag-list__heading" id="tags">
|
||||
Tags
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#method_setAllowedTypes#tags" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h5>
|
||||
<dl class="phpdocumentor-tag-list">
|
||||
<dt class="phpdocumentor-tag-list__entry">
|
||||
<span class="phpdocumentor-tag__name">throws</span>
|
||||
</dt>
|
||||
<dd class="phpdocumentor-tag-list__definition">
|
||||
<span class="phpdocumentor-tag-link"><abbr title="\InvalidArgumentException">InvalidArgumentException</abbr></span>
|
||||
|
||||
<section class="phpdocumentor-description"><p>if any value of <code class="prettyprint">$allowedTypes</code> is not a string</p>
|
||||
</section>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<div class="phpdocumentor-modal" id="source-view">
|
||||
<div class="phpdocumentor-modal-bg" data-exit-button></div>
|
||||
<div class="phpdocumentor-modal-container">
|
||||
<div class="phpdocumentor-modal-content">
|
||||
<pre style="max-height: 500px; overflow-y: scroll" data-src="files/src/Traits/TypeChecker.php.txt" class="language-php line-numbers linkable-line-numbers"></pre>
|
||||
</div>
|
||||
<button data-exit-button class="phpdocumentor-modal__close">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
function loadExternalCodeSnippet(el, url, line) {
|
||||
Array.prototype.slice.call(el.querySelectorAll('pre[data-src]')).forEach((pre) => {
|
||||
const src = url || pre.getAttribute('data-src').replace(/\\/g, '/');
|
||||
const language = 'php';
|
||||
|
||||
const code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
pre.textContent = '';
|
||||
pre.setAttribute('data-line', line)
|
||||
code.textContent = 'Loading…';
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
Prism.highlightElement(code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status === 404) {
|
||||
code.textContent = '✖ Error: File could not be found';
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
return;
|
||||
}
|
||||
|
||||
code.textContent = '✖ Error: An unknown error occurred';
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
const modalButtons = document.querySelectorAll("[data-modal]");
|
||||
const openedAsLocalFile = window.location.protocol === 'file:';
|
||||
if (modalButtons.length > 0 && openedAsLocalFile) {
|
||||
console.warn(
|
||||
'Viewing the source code is unavailable because you are opening this page from the file:// scheme; ' +
|
||||
'browsers block XHR requests when a page is opened this way'
|
||||
);
|
||||
}
|
||||
|
||||
modalButtons.forEach(function (trigger) {
|
||||
if (openedAsLocalFile) {
|
||||
trigger.setAttribute("hidden", "hidden");
|
||||
}
|
||||
|
||||
trigger.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
const modal = document.getElementById(trigger.dataset.modal);
|
||||
if (!modal) {
|
||||
console.error(`Modal with id "${trigger.dataset.modal}" could not be found`);
|
||||
return;
|
||||
}
|
||||
modal.classList.add("phpdocumentor-modal__open");
|
||||
|
||||
loadExternalCodeSnippet(modal, trigger.dataset.src || null, trigger.dataset.line)
|
||||
const exits = modal.querySelectorAll("[data-exit-button]");
|
||||
exits.forEach(function (exit) {
|
||||
exit.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
modal.classList.remove("phpdocumentor-modal__open");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
</article>
|
||||
</section>
|
||||
<section class="phpdocumentor-on-this-page__sidebar">
|
||||
|
||||
<section class="phpdocumentor-on-this-page__content">
|
||||
<strong class="phpdocumentor-on-this-page__title">On this page</strong>
|
||||
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li class="phpdocumentor-on-this-page-section__title">Table Of Contents</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="classes/OCC-Basics-Traits-TypeChecker.html#toc-methods">Methods</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="phpdocumentor-on-this-page-section__title">Methods</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="classes/OCC-Basics-Traits-TypeChecker.html#method_getAllowedTypes">getAllowedTypes()</a></li>
|
||||
<li><a href="classes/OCC-Basics-Traits-TypeChecker.html#method_hasAllowedType">hasAllowedType()</a></li>
|
||||
<li><a href="classes/OCC-Basics-Traits-TypeChecker.html#method_isAllowedType">isAllowedType()</a></li>
|
||||
<li><a href="classes/OCC-Basics-Traits-TypeChecker.html#method_setAllowedTypes">setAllowedTypes()</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="classes/OCC-Basics-Traits-TypeChecker.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -311,6 +311,8 @@ aside.phpdocumentor-sidebar
|
|||
padding: 0 var(--spacing-md) !important;
|
||||
}
|
||||
|
||||
p > code,
|
||||
li > code,
|
||||
code.prettyprint
|
||||
{
|
||||
background-color: var(--code-background-color);
|
||||
|
@ -321,6 +323,38 @@ code.prettyprint
|
|||
padding: var(--spacing-xxxs);
|
||||
}
|
||||
|
||||
@media (max-width: 999px) {
|
||||
div.admonition-wrapper
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1000px) {
|
||||
div.admonition-wrapper
|
||||
{
|
||||
display: block;
|
||||
float: right;
|
||||
padding: var(--spacing-md);
|
||||
margin: 0 0 var(--spacing-md) var(--spacing-md);
|
||||
width: auto;
|
||||
font-size: var(--text-sm);
|
||||
border: 1px solid var(--primary-color-lighten);
|
||||
}
|
||||
}
|
||||
|
||||
div.admonition-wrapper
|
||||
p.sidebar-title
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.contents
|
||||
ul.phpdocumentor-list
|
||||
{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.phpdocumentor-content
|
||||
div.section
|
||||
ul
|
||||
|
|
|
@ -0,0 +1,362 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<section>
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
</ul>
|
||||
|
||||
<article class="phpdocumentor-element -file">
|
||||
<h2 class="phpdocumentor-content__title">InvalidDataTypeException.php</h2>
|
||||
|
||||
<p class="phpdocumentor-summary">PHP Basics</p>
|
||||
|
||||
<section class="phpdocumentor-description"><p>Copyright (C) 2024 Sebastian Meyer <a href="mailto:sebastian.meyer@opencultureconsulting.com">sebastian.meyer@opencultureconsulting.com</a></p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<p>You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.</p>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 id="toc">
|
||||
Table of Contents
|
||||
<a href="files/src-datastructures-exceptions-invaliddatatypeexception.html#toc" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 id="toc-classes">
|
||||
Classes
|
||||
<a href="files/src-datastructures-exceptions-invaliddatatypeexception.html#toc-classes" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -class"><a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html"><abbr title="\OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException">InvalidDataTypeException</abbr></a></dt><dd>Common exception for type-sensitive datastructures.</dd> </dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="phpdocumentor-modal" id="source-view">
|
||||
<div class="phpdocumentor-modal-bg" data-exit-button></div>
|
||||
<div class="phpdocumentor-modal-container">
|
||||
<div class="phpdocumentor-modal-content">
|
||||
<pre style="max-height: 500px; overflow-y: scroll" data-src="files/src/DataStructures/Exceptions/InvalidDataTypeException.php.txt" class="language-php line-numbers linkable-line-numbers"></pre>
|
||||
</div>
|
||||
<button data-exit-button class="phpdocumentor-modal__close">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
function loadExternalCodeSnippet(el, url, line) {
|
||||
Array.prototype.slice.call(el.querySelectorAll('pre[data-src]')).forEach((pre) => {
|
||||
const src = url || pre.getAttribute('data-src').replace(/\\/g, '/');
|
||||
const language = 'php';
|
||||
|
||||
const code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
pre.textContent = '';
|
||||
pre.setAttribute('data-line', line)
|
||||
code.textContent = 'Loading…';
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
Prism.highlightElement(code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status === 404) {
|
||||
code.textContent = '✖ Error: File could not be found';
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
return;
|
||||
}
|
||||
|
||||
code.textContent = '✖ Error: An unknown error occurred';
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
const modalButtons = document.querySelectorAll("[data-modal]");
|
||||
const openedAsLocalFile = window.location.protocol === 'file:';
|
||||
if (modalButtons.length > 0 && openedAsLocalFile) {
|
||||
console.warn(
|
||||
'Viewing the source code is unavailable because you are opening this page from the file:// scheme; ' +
|
||||
'browsers block XHR requests when a page is opened this way'
|
||||
);
|
||||
}
|
||||
|
||||
modalButtons.forEach(function (trigger) {
|
||||
if (openedAsLocalFile) {
|
||||
trigger.setAttribute("hidden", "hidden");
|
||||
}
|
||||
|
||||
trigger.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
const modal = document.getElementById(trigger.dataset.modal);
|
||||
if (!modal) {
|
||||
console.error(`Modal with id "${trigger.dataset.modal}" could not be found`);
|
||||
return;
|
||||
}
|
||||
modal.classList.add("phpdocumentor-modal__open");
|
||||
|
||||
loadExternalCodeSnippet(modal, trigger.dataset.src || null, trigger.dataset.line)
|
||||
const exits = modal.querySelectorAll("[data-exit-button]");
|
||||
exits.forEach(function (exit) {
|
||||
exit.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
modal.classList.remove("phpdocumentor-modal__open");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
</article>
|
||||
</section>
|
||||
<section class="phpdocumentor-on-this-page__sidebar">
|
||||
|
||||
<section class="phpdocumentor-on-this-page__content">
|
||||
<strong class="phpdocumentor-on-this-page__title">On this page</strong>
|
||||
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li class="phpdocumentor-on-this-page-section__title">Table Of Contents</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="files/src-datastructures-exceptions-invaliddatatypeexception.html#toc-classes">Classes</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="files/src-datastructures-exceptions-invaliddatatypeexception.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -0,0 +1,362 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<section>
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
</ul>
|
||||
|
||||
<article class="phpdocumentor-element -file">
|
||||
<h2 class="phpdocumentor-content__title">StrictSplDatastructureTrait.php</h2>
|
||||
|
||||
<p class="phpdocumentor-summary">PHP Basics</p>
|
||||
|
||||
<section class="phpdocumentor-description"><p>Copyright (C) 2024 Sebastian Meyer <a href="mailto:sebastian.meyer@opencultureconsulting.com">sebastian.meyer@opencultureconsulting.com</a></p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<p>You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.</p>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 id="toc">
|
||||
Table of Contents
|
||||
<a href="files/src-datastructures-strictspldatastructuretrait.html#toc" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 id="toc-traits">
|
||||
Traits
|
||||
<a href="files/src-datastructures-strictspldatastructuretrait.html#toc-traits" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-DataStructures-StrictSplDatastructureTrait.html"><abbr title="\OCC\Basics\DataStructures\StrictSplDatastructureTrait">StrictSplDatastructureTrait</abbr></a></dt><dd>The common interface of all type-sensitive, SPL-based datastructures.</dd> </dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="phpdocumentor-modal" id="source-view">
|
||||
<div class="phpdocumentor-modal-bg" data-exit-button></div>
|
||||
<div class="phpdocumentor-modal-container">
|
||||
<div class="phpdocumentor-modal-content">
|
||||
<pre style="max-height: 500px; overflow-y: scroll" data-src="files/src/DataStructures/StrictSplDatastructureTrait.php.txt" class="language-php line-numbers linkable-line-numbers"></pre>
|
||||
</div>
|
||||
<button data-exit-button class="phpdocumentor-modal__close">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
function loadExternalCodeSnippet(el, url, line) {
|
||||
Array.prototype.slice.call(el.querySelectorAll('pre[data-src]')).forEach((pre) => {
|
||||
const src = url || pre.getAttribute('data-src').replace(/\\/g, '/');
|
||||
const language = 'php';
|
||||
|
||||
const code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
pre.textContent = '';
|
||||
pre.setAttribute('data-line', line)
|
||||
code.textContent = 'Loading…';
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
Prism.highlightElement(code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status === 404) {
|
||||
code.textContent = '✖ Error: File could not be found';
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
return;
|
||||
}
|
||||
|
||||
code.textContent = '✖ Error: An unknown error occurred';
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
const modalButtons = document.querySelectorAll("[data-modal]");
|
||||
const openedAsLocalFile = window.location.protocol === 'file:';
|
||||
if (modalButtons.length > 0 && openedAsLocalFile) {
|
||||
console.warn(
|
||||
'Viewing the source code is unavailable because you are opening this page from the file:// scheme; ' +
|
||||
'browsers block XHR requests when a page is opened this way'
|
||||
);
|
||||
}
|
||||
|
||||
modalButtons.forEach(function (trigger) {
|
||||
if (openedAsLocalFile) {
|
||||
trigger.setAttribute("hidden", "hidden");
|
||||
}
|
||||
|
||||
trigger.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
const modal = document.getElementById(trigger.dataset.modal);
|
||||
if (!modal) {
|
||||
console.error(`Modal with id "${trigger.dataset.modal}" could not be found`);
|
||||
return;
|
||||
}
|
||||
modal.classList.add("phpdocumentor-modal__open");
|
||||
|
||||
loadExternalCodeSnippet(modal, trigger.dataset.src || null, trigger.dataset.line)
|
||||
const exits = modal.querySelectorAll("[data-exit-button]");
|
||||
exits.forEach(function (exit) {
|
||||
exit.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
modal.classList.remove("phpdocumentor-modal__open");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
</article>
|
||||
</section>
|
||||
<section class="phpdocumentor-on-this-page__sidebar">
|
||||
|
||||
<section class="phpdocumentor-on-this-page__content">
|
||||
<strong class="phpdocumentor-on-this-page__title">On this page</strong>
|
||||
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li class="phpdocumentor-on-this-page-section__title">Table Of Contents</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="files/src-datastructures-strictspldatastructuretrait.html#toc-traits">Traits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="files/src-datastructures-strictspldatastructuretrait.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -0,0 +1,362 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<section>
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
</ul>
|
||||
|
||||
<article class="phpdocumentor-element -file">
|
||||
<h2 class="phpdocumentor-content__title">StrictSplDatastructureTrait.php</h2>
|
||||
|
||||
<p class="phpdocumentor-summary">PHP Basics</p>
|
||||
|
||||
<section class="phpdocumentor-description"><p>Copyright (C) 2024 Sebastian Meyer <a href="mailto:sebastian.meyer@opencultureconsulting.com">sebastian.meyer@opencultureconsulting.com</a></p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<p>You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.</p>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 id="toc">
|
||||
Table of Contents
|
||||
<a href="files/src-datastructures-traits-strictspldatastructuretrait.html#toc" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 id="toc-traits">
|
||||
Traits
|
||||
<a href="files/src-datastructures-traits-strictspldatastructuretrait.html#toc-traits" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html"><abbr title="\OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait">StrictSplDatastructureTrait</abbr></a></dt><dd>The common interface of all type-sensitive, SPL-based datastructures.</dd> </dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="phpdocumentor-modal" id="source-view">
|
||||
<div class="phpdocumentor-modal-bg" data-exit-button></div>
|
||||
<div class="phpdocumentor-modal-container">
|
||||
<div class="phpdocumentor-modal-content">
|
||||
<pre style="max-height: 500px; overflow-y: scroll" data-src="files/src/DataStructures/Traits/StrictSplDatastructureTrait.php.txt" class="language-php line-numbers linkable-line-numbers"></pre>
|
||||
</div>
|
||||
<button data-exit-button class="phpdocumentor-modal__close">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
function loadExternalCodeSnippet(el, url, line) {
|
||||
Array.prototype.slice.call(el.querySelectorAll('pre[data-src]')).forEach((pre) => {
|
||||
const src = url || pre.getAttribute('data-src').replace(/\\/g, '/');
|
||||
const language = 'php';
|
||||
|
||||
const code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
pre.textContent = '';
|
||||
pre.setAttribute('data-line', line)
|
||||
code.textContent = 'Loading…';
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
Prism.highlightElement(code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status === 404) {
|
||||
code.textContent = '✖ Error: File could not be found';
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
return;
|
||||
}
|
||||
|
||||
code.textContent = '✖ Error: An unknown error occurred';
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
const modalButtons = document.querySelectorAll("[data-modal]");
|
||||
const openedAsLocalFile = window.location.protocol === 'file:';
|
||||
if (modalButtons.length > 0 && openedAsLocalFile) {
|
||||
console.warn(
|
||||
'Viewing the source code is unavailable because you are opening this page from the file:// scheme; ' +
|
||||
'browsers block XHR requests when a page is opened this way'
|
||||
);
|
||||
}
|
||||
|
||||
modalButtons.forEach(function (trigger) {
|
||||
if (openedAsLocalFile) {
|
||||
trigger.setAttribute("hidden", "hidden");
|
||||
}
|
||||
|
||||
trigger.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
const modal = document.getElementById(trigger.dataset.modal);
|
||||
if (!modal) {
|
||||
console.error(`Modal with id "${trigger.dataset.modal}" could not be found`);
|
||||
return;
|
||||
}
|
||||
modal.classList.add("phpdocumentor-modal__open");
|
||||
|
||||
loadExternalCodeSnippet(modal, trigger.dataset.src || null, trigger.dataset.line)
|
||||
const exits = modal.querySelectorAll("[data-exit-button]");
|
||||
exits.forEach(function (exit) {
|
||||
exit.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
modal.classList.remove("phpdocumentor-modal__open");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
</article>
|
||||
</section>
|
||||
<section class="phpdocumentor-on-this-page__sidebar">
|
||||
|
||||
<section class="phpdocumentor-on-this-page__content">
|
||||
<strong class="phpdocumentor-on-this-page__title">On this page</strong>
|
||||
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li class="phpdocumentor-on-this-page-section__title">Table Of Contents</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="files/src-datastructures-traits-strictspldatastructuretrait.html#toc-traits">Traits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="files/src-datastructures-traits-strictspldatastructuretrait.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -0,0 +1,362 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<section>
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
</ul>
|
||||
|
||||
<article class="phpdocumentor-element -file">
|
||||
<h2 class="phpdocumentor-content__title">TypeChecker.php</h2>
|
||||
|
||||
<p class="phpdocumentor-summary">PHP Basics</p>
|
||||
|
||||
<section class="phpdocumentor-description"><p>Copyright (C) 2024 Sebastian Meyer <a href="mailto:sebastian.meyer@opencultureconsulting.com">sebastian.meyer@opencultureconsulting.com</a></p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<p>You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.</p>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 id="toc">
|
||||
Table of Contents
|
||||
<a href="files/src-traits-typechecker.html#toc" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 id="toc-traits">
|
||||
Traits
|
||||
<a href="files/src-traits-typechecker.html#toc-traits" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-TypeChecker.html"><abbr title="\OCC\Basics\Traits\TypeChecker">TypeChecker</abbr></a></dt><dd>A generic data type checker.</dd> </dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="phpdocumentor-modal" id="source-view">
|
||||
<div class="phpdocumentor-modal-bg" data-exit-button></div>
|
||||
<div class="phpdocumentor-modal-container">
|
||||
<div class="phpdocumentor-modal-content">
|
||||
<pre style="max-height: 500px; overflow-y: scroll" data-src="files/src/Traits/TypeChecker.php.txt" class="language-php line-numbers linkable-line-numbers"></pre>
|
||||
</div>
|
||||
<button data-exit-button class="phpdocumentor-modal__close">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
function loadExternalCodeSnippet(el, url, line) {
|
||||
Array.prototype.slice.call(el.querySelectorAll('pre[data-src]')).forEach((pre) => {
|
||||
const src = url || pre.getAttribute('data-src').replace(/\\/g, '/');
|
||||
const language = 'php';
|
||||
|
||||
const code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
pre.textContent = '';
|
||||
pre.setAttribute('data-line', line)
|
||||
code.textContent = 'Loading…';
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
Prism.highlightElement(code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status === 404) {
|
||||
code.textContent = '✖ Error: File could not be found';
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
return;
|
||||
}
|
||||
|
||||
code.textContent = '✖ Error: An unknown error occurred';
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
const modalButtons = document.querySelectorAll("[data-modal]");
|
||||
const openedAsLocalFile = window.location.protocol === 'file:';
|
||||
if (modalButtons.length > 0 && openedAsLocalFile) {
|
||||
console.warn(
|
||||
'Viewing the source code is unavailable because you are opening this page from the file:// scheme; ' +
|
||||
'browsers block XHR requests when a page is opened this way'
|
||||
);
|
||||
}
|
||||
|
||||
modalButtons.forEach(function (trigger) {
|
||||
if (openedAsLocalFile) {
|
||||
trigger.setAttribute("hidden", "hidden");
|
||||
}
|
||||
|
||||
trigger.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
const modal = document.getElementById(trigger.dataset.modal);
|
||||
if (!modal) {
|
||||
console.error(`Modal with id "${trigger.dataset.modal}" could not be found`);
|
||||
return;
|
||||
}
|
||||
modal.classList.add("phpdocumentor-modal__open");
|
||||
|
||||
loadExternalCodeSnippet(modal, trigger.dataset.src || null, trigger.dataset.line)
|
||||
const exits = modal.querySelectorAll("[data-exit-button]");
|
||||
exits.forEach(function (exit) {
|
||||
exit.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
modal.classList.remove("phpdocumentor-modal__open");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
</article>
|
||||
</section>
|
||||
<section class="phpdocumentor-on-this-page__sidebar">
|
||||
|
||||
<section class="phpdocumentor-on-this-page__content">
|
||||
<strong class="phpdocumentor-on-this-page__title">On this page</strong>
|
||||
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li class="phpdocumentor-on-this-page-section__title">Table Of Contents</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="files/src-traits-typechecker.html#toc-traits">Traits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="files/src-traits-typechecker.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCC\Basics\DataStructures\Exceptions;
|
||||
|
||||
use DomainException;
|
||||
|
||||
/**
|
||||
* Common exception for type-sensitive datastructures.
|
||||
*
|
||||
* Exception thrown if a value does not adhere to the defined list of valid
|
||||
* data types.
|
||||
*
|
||||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\DataStructures
|
||||
*/
|
||||
class InvalidDataTypeException extends DomainException
|
||||
{
|
||||
}
|
|
@ -27,35 +27,17 @@ use ArrayAccess;
|
|||
use Countable;
|
||||
use DomainException;
|
||||
use InvalidArgumentException;
|
||||
use OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException;
|
||||
use OCC\Basics\Interfaces\ArrayAccessTrait;
|
||||
use OCC\Basics\Interfaces\CountableTrait;
|
||||
use OCC\Basics\Traits\Getter;
|
||||
use OCC\Basics\Traits\TypeChecker;
|
||||
use OutOfRangeException;
|
||||
use Serializable;
|
||||
|
||||
use function array_is_list;
|
||||
use function array_map;
|
||||
use function array_sum;
|
||||
use function count;
|
||||
use function function_exists;
|
||||
use function get_debug_type;
|
||||
use function is_a;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_callable;
|
||||
use function is_countable;
|
||||
use function is_double;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
use function is_integer;
|
||||
use function is_iterable;
|
||||
use function is_long;
|
||||
use function is_null;
|
||||
use function is_numeric;
|
||||
use function is_resource;
|
||||
use function is_scalar;
|
||||
use function is_string;
|
||||
use function is_object;
|
||||
use function ltrim;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function unserialize;
|
||||
|
@ -73,8 +55,6 @@ use function unserialize;
|
|||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\DataStructures
|
||||
*
|
||||
* @property-read string[] $allowedTypes The allowed data types for items.
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @template AllowedType of mixed
|
||||
|
@ -86,35 +66,28 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
use ArrayAccessTrait;
|
||||
/** @use CountableTrait<AllowedType> */
|
||||
use CountableTrait;
|
||||
use Getter;
|
||||
|
||||
/**
|
||||
* The allowed data types for collection items.
|
||||
*
|
||||
* @var string[]
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected array $allowedTypes = [];
|
||||
use TypeChecker {
|
||||
setAllowedTypes as protected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds the collection's items.
|
||||
*
|
||||
* @var AllowedType[]
|
||||
* @var array<array-key, AllowedType>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected array $_data = [];
|
||||
|
||||
/**
|
||||
* Add/insert a new item at the specified index.
|
||||
* Add/insert a item at the specified index.
|
||||
*
|
||||
* @param array-key $offset The new item's index
|
||||
* @param AllowedType $value The new item
|
||||
* @param array-key $offset The item's index
|
||||
* @param AllowedType $value The item
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if `$offset` is not of allowed type
|
||||
* @throws InvalidDataTypeException if `$value` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -140,53 +113,25 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
*
|
||||
* @param array-key $offset The item's index
|
||||
*
|
||||
* @return ?AllowedType The item or NULL if key is invalid
|
||||
* @return AllowedType The item
|
||||
*
|
||||
* @throws OutOfRangeException when `$offset` is out of bounds
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function get(int|string $offset): mixed
|
||||
{
|
||||
return $this->offsetGet($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allowed data types for collection items.
|
||||
*
|
||||
* @return string[] The list of allowed data types
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getAllowedTypes(): array
|
||||
{
|
||||
return $this->allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the item's data type is allowed in the collection.
|
||||
*
|
||||
* @param AllowedType $value The item to check
|
||||
*
|
||||
* @return bool Whether the item's data type is allowed
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isAllowedType(mixed $value): bool
|
||||
{
|
||||
if (count($this->allowedTypes) === 0) {
|
||||
return true;
|
||||
if (!$this->offsetExists($offset)) {
|
||||
throw new OutOfRangeException(
|
||||
sprintf(
|
||||
'Offset %s is not a valid index key for this collection.',
|
||||
$offset
|
||||
)
|
||||
);
|
||||
}
|
||||
foreach ($this->allowedTypes as $type) {
|
||||
$function = 'is_' . $type;
|
||||
if (function_exists($function) && $function($value)) {
|
||||
return true;
|
||||
}
|
||||
/** @var class-string $fqcn */
|
||||
$fqcn = ltrim($type, '\\');
|
||||
if (is_object($value) && is_a($value, $fqcn)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
/** @var AllowedType $value */
|
||||
$value = $this->offsetGet($offset);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,7 +171,8 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if `$offset` or `$value` is not of allowed type
|
||||
* @throws InvalidDataTypeException if `$value` is not of allowed type
|
||||
* @throws InvalidArgumentException if `$offset` is not a valid array key
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -240,8 +186,8 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
)
|
||||
);
|
||||
}
|
||||
if (!$this->isAllowedType($value)) {
|
||||
throw new InvalidArgumentException(
|
||||
if (!$this->hasAllowedType($value)) {
|
||||
throw new InvalidDataTypeException(
|
||||
sprintf(
|
||||
'Parameter 2 must be an allowed type, %s given.',
|
||||
get_debug_type($value)
|
||||
|
@ -258,10 +204,20 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws OutOfRangeException when `$offset` is out of bounds
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function remove(int|string $offset): void
|
||||
{
|
||||
if (!$this->offsetExists($offset)) {
|
||||
throw new OutOfRangeException(
|
||||
sprintf(
|
||||
'Offset %s is not a valid index key for this collection.',
|
||||
$offset
|
||||
)
|
||||
);
|
||||
}
|
||||
$this->offsetUnset($offset);
|
||||
}
|
||||
|
||||
|
@ -283,7 +239,7 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if `$value` is not of allowed type
|
||||
* @throws InvalidDataTypeException if `$value` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -292,29 +248,10 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
$this->offsetSet($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set allowed data types of collection items.
|
||||
*
|
||||
* @param string[] $allowedTypes Allowed data types of items
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if any value of `$allowedTypes` is not a string
|
||||
*/
|
||||
protected function setAllowedTypes(array $allowedTypes = []): void
|
||||
{
|
||||
if (array_sum(array_map('is_string', $allowedTypes)) !== count($allowedTypes)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Allowed types must be array of strings or empty array.'
|
||||
);
|
||||
}
|
||||
$this->allowedTypes = $allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array representation of collection.
|
||||
*
|
||||
* @return AllowedType[] Array of collection items
|
||||
* @return array<array-key, AllowedType> Array of collection items
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -338,12 +275,11 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
{
|
||||
if (!$this->isList()) {
|
||||
throw new DomainException(
|
||||
'Cannot convert into list: collection contains non-integer and/or non-consecutive keys.'
|
||||
'Cannot convert into StrictList: collection contains non-integer and/or non-consecutive keys.'
|
||||
);
|
||||
}
|
||||
$strictList = new StrictList($this->allowedTypes);
|
||||
$items = $this->toArray();
|
||||
$strictList->append(...$items);
|
||||
$strictList = new StrictList($this->getAllowedTypes());
|
||||
$strictList->append(...$this->toArray());
|
||||
return $strictList;
|
||||
}
|
||||
|
||||
|
@ -361,18 +297,6 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
$this->__unserialize($dataArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter method for $this->allowedTypes.
|
||||
*
|
||||
* @return string[] The list of allowed data types
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function _magicGetAllowedTypes(): array
|
||||
{
|
||||
return $this->getAllowedTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a type-sensitive collection of items.
|
||||
*
|
||||
|
@ -425,8 +349,8 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
public function __serialize(): array
|
||||
{
|
||||
return [
|
||||
'StrictCollection::allowedTypes' => $this->allowedTypes,
|
||||
'StrictCollection::items' => $this->_data
|
||||
'StrictCollection::allowedTypes' => $this->getAllowedTypes(),
|
||||
'StrictCollection::items' => $this->toArray()
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -446,7 +370,7 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
/** @var string[] $allowedTypes */
|
||||
$allowedTypes = $data['StrictCollection::allowedTypes'];
|
||||
$this->setAllowedTypes($allowedTypes);
|
||||
/** @var AllowedType[] $items */
|
||||
/** @var array<array-key, AllowedType> $items */
|
||||
$items = $data['StrictCollection::items'];
|
||||
foreach ($items as $offset => $value) {
|
||||
$this->offsetSet($offset, $value);
|
||||
|
|
|
@ -23,46 +23,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCC\Basics\DataStructures;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use InvalidArgumentException;
|
||||
use Iterator;
|
||||
use OutOfRangeException;
|
||||
use RangeException;
|
||||
use RuntimeException;
|
||||
use OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait;
|
||||
use SplDoublyLinkedList;
|
||||
use OCC\Basics\Traits\Getter;
|
||||
use Serializable;
|
||||
|
||||
use function array_map;
|
||||
use function array_sum;
|
||||
use function count;
|
||||
use function function_exists;
|
||||
use function get_debug_type;
|
||||
use function in_array;
|
||||
use function is_a;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_callable;
|
||||
use function is_countable;
|
||||
use function is_double;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
use function is_integer;
|
||||
use function is_iterable;
|
||||
use function is_long;
|
||||
use function is_null;
|
||||
use function is_numeric;
|
||||
use function is_resource;
|
||||
use function is_scalar;
|
||||
use function is_string;
|
||||
use function is_object;
|
||||
use function iterator_to_array;
|
||||
use function ltrim;
|
||||
use function range;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* A type-sensitive, taversable list.
|
||||
|
@ -74,709 +36,13 @@ use function unserialize;
|
|||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\DataStructures
|
||||
*
|
||||
* @property-read string[] $allowedTypes The allowed data types for values.
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @template AllowedType of mixed
|
||||
* @extends SplDoublyLinkedList<AllowedType>
|
||||
* @implements ArrayAccess<int, AllowedType>
|
||||
* @implements Iterator<AllowedType>
|
||||
*/
|
||||
class StrictList extends SplDoublyLinkedList implements ArrayAccess, Countable, Iterator, Serializable
|
||||
class StrictList extends SplDoublyLinkedList
|
||||
{
|
||||
use Getter;
|
||||
|
||||
/**
|
||||
* The allowed data types for list items.
|
||||
*
|
||||
* @var string[]
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected array $allowedTypes = [];
|
||||
|
||||
/**
|
||||
* 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<int, AllowedType> $values */
|
||||
foreach ($values as $count => $value) {
|
||||
if (!$this->isAllowedType($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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Peek at the item at the beginning of the list.
|
||||
*
|
||||
* @return AllowedType The first item of the list
|
||||
*
|
||||
* @throws RuntimeException if the list is empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function bottom(): mixed
|
||||
{
|
||||
return parent::bottom();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the list of any items.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function clear(): void
|
||||
{
|
||||
while (!$this->isEmpty()) {
|
||||
$this->pop();
|
||||
}
|
||||
$this->rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of items on the list.
|
||||
*
|
||||
* @return int The number of items on the list
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return parent::count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current list item.
|
||||
*
|
||||
* @return AllowedType The current item
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function current(): mixed
|
||||
{
|
||||
return parent::current();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allowed data types for list items.
|
||||
*
|
||||
* @return string[] The list of allowed data types
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getAllowedTypes(): array
|
||||
{
|
||||
return $this->allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mode of iteration.
|
||||
*
|
||||
* @return int The set of flags and modes of iteration
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getIteratorMode(): int
|
||||
{
|
||||
return parent::getIteratorMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the item's data type is allowed on the list.
|
||||
*
|
||||
* @param AllowedType $value The item to check
|
||||
*
|
||||
* @return bool Whether the item's data type is allowed
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isAllowedType(mixed $value): bool
|
||||
{
|
||||
if (count($this->allowedTypes) === 0) {
|
||||
return true;
|
||||
}
|
||||
foreach ($this->allowedTypes as $type) {
|
||||
$function = 'is_' . $type;
|
||||
if (function_exists($function) && $function($value)) {
|
||||
return true;
|
||||
}
|
||||
/** @var class-string $fqcn */
|
||||
$fqcn = ltrim($type, '\\');
|
||||
if (is_object($value) && is_a($value, $fqcn)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if list is empty.
|
||||
*
|
||||
* @return bool Whether the list contains no items
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return parent::isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current list index.
|
||||
*
|
||||
* @return int The current list index
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function key(): int
|
||||
{
|
||||
return parent::key();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the cursor to the next list index.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function next(): void
|
||||
{
|
||||
parent::next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the specified index exists and is not empty.
|
||||
*
|
||||
* @param int $offset The index to check
|
||||
*
|
||||
* @return bool Whether the index exists and is not empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function offsetExists(mixed $offset): bool
|
||||
{
|
||||
return parent::offsetExists($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item from 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 offsetGet(mixed $offset): mixed
|
||||
{
|
||||
return parent::offsetGet($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->isAllowedType($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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the item at the specified index.
|
||||
*
|
||||
* @param int $offset The item's index
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws OutOfRangeException when `$offset` is out of bounds
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function offsetUnset(mixed $offset): void
|
||||
{
|
||||
parent::offsetUnset($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pops an item from the end of the list.
|
||||
*
|
||||
* @return AllowedType The item from the end of the list
|
||||
*
|
||||
* @throws RuntimeException if the list is empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function pop(): mixed
|
||||
{
|
||||
return parent::pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<int, AllowedType> $values */
|
||||
foreach ($values as $count => $value) {
|
||||
if (!$this->isAllowedType($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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the cursor to the previous list index.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function prev(): void
|
||||
{
|
||||
parent::prev();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->isAllowedType($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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind the iterator's cursor.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function rewind(): void
|
||||
{
|
||||
parent::rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set allowed data types of list items.
|
||||
*
|
||||
* @param string[] $allowedTypes Allowed data types of items
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if any value of `$allowedTypes` is not a string
|
||||
*/
|
||||
protected function setAllowedTypes(array $allowedTypes = []): void
|
||||
{
|
||||
if (array_sum(array_map('is_string', $allowedTypes)) !== count($allowedTypes)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Allowed types must be array of strings or empty array.'
|
||||
);
|
||||
}
|
||||
$this->allowedTypes = $allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mode of iteration.
|
||||
*
|
||||
* @param int $mode The new iterator mode (0, 1, 2 or 3)
|
||||
*
|
||||
* There are two orthogonal sets of modes that can be set.
|
||||
*
|
||||
* The direction of iteration (either one or the other):
|
||||
* - StrictList::IT_MODE_FIFO (queue style)
|
||||
* - StrictList::IT_MODE_LIFO (stack style)
|
||||
*
|
||||
* The behavior of the iterator (either one or the other):
|
||||
* - StrictList::IT_MODE_DELETE (delete items)
|
||||
* - StrictList::IT_MODE_KEEP (keep items)
|
||||
*
|
||||
* The default mode is: IT_MODE_FIFO | IT_MODE_KEEP
|
||||
*
|
||||
* @return int The set of flags and modes of iteration
|
||||
*
|
||||
* @throws RangeException if an invalid `$mode` is given
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setIteratorMode(int $mode): int
|
||||
{
|
||||
if (!in_array($mode, range(0, 3), true)) {
|
||||
throw new RangeException(
|
||||
sprintf(
|
||||
'Iterator mode must be an integer in range [0..3], %d given.',
|
||||
$mode
|
||||
)
|
||||
);
|
||||
}
|
||||
return parent::setIteratorMode($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift an item from the beginning of the list.
|
||||
*
|
||||
* @return AllowedType The first item of the list
|
||||
*
|
||||
* @throws RuntimeException if the list is empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function shift(): mixed
|
||||
{
|
||||
return parent::shift();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array representation of list.
|
||||
*
|
||||
* @return AllowedType[] Array of list items
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return iterator_to_array($this, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn list into a type-sensitive collection.
|
||||
*
|
||||
* @return StrictCollection<AllowedType> A type-sensitive collection of the list's items
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function toStrictCollection(): StrictCollection
|
||||
{
|
||||
$strictCollection = new StrictCollection($this->allowedTypes);
|
||||
foreach ($this->toArray() as $offset => $value) {
|
||||
$strictCollection[$offset] = $value;
|
||||
}
|
||||
return $strictCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Peek at the item at the end of the list.
|
||||
*
|
||||
* @return AllowedType The last item of the list
|
||||
*
|
||||
* @throws RuntimeException if the list is empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function top(): mixed
|
||||
{
|
||||
return parent::top();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->isAllowedType($value)) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'Parameter 1 must be an allowed type, %s given.',
|
||||
get_debug_type($value)
|
||||
)
|
||||
);
|
||||
}
|
||||
parent::unshift($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current cursor position is valid.
|
||||
*
|
||||
* @return bool Whether the current cursor position is valid
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function valid(): bool
|
||||
{
|
||||
return parent::valid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter method for $this->allowedTypes.
|
||||
*
|
||||
* @return string[] The list of allowed data types
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function _magicGetAllowedTypes(): array
|
||||
{
|
||||
return $this->getAllowedTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 [
|
||||
'StrictList::allowedTypes' => $this->allowedTypes,
|
||||
'SplDoublyLinkedList::dllist' => iterator_to_array($this),
|
||||
'SplDoublyLinkedList::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['StrictList::allowedTypes'];
|
||||
$this->setAllowedTypes($allowedTypes);
|
||||
/** @var array<int, AllowedType> $values */
|
||||
$values = $data['SplDoublyLinkedList::dllist'];
|
||||
$this->append(...$values);
|
||||
/** @var int $flags */
|
||||
$flags = $data['SplDoublyLinkedList::flags'];
|
||||
$this->setIteratorMode($flags);
|
||||
}
|
||||
/** @use StrictSplDatastructureTrait<AllowedType> */
|
||||
use StrictSplDatastructureTrait;
|
||||
}
|
||||
|
|
|
@ -23,24 +23,16 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCC\Basics\DataStructures;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use InvalidArgumentException;
|
||||
use Iterator;
|
||||
use RangeException;
|
||||
use RuntimeException;
|
||||
use Serializable;
|
||||
|
||||
use function sprintf;
|
||||
use OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException;
|
||||
use OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait;
|
||||
use SplQueue;
|
||||
|
||||
/**
|
||||
* A type-sensitive, taversable queue (FIFO).
|
||||
*
|
||||
* Extends [\SplDoublyLinkedList](https://www.php.net/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. It
|
||||
* also restricts the iterator direction to first-in, first-out (FIFO) exactly
|
||||
* like [\SplQueue](https://www.php.net/splqueue).
|
||||
* Extends [\SplQueue](https://www.php.net/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.
|
||||
*
|
||||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\DataStructures
|
||||
|
@ -48,23 +40,12 @@ use function sprintf;
|
|||
* @api
|
||||
*
|
||||
* @template AllowedType of mixed
|
||||
* @extends StrictList<AllowedType>
|
||||
* @implements ArrayAccess<int, AllowedType>
|
||||
* @implements Iterator<AllowedType>
|
||||
* @extends SplQueue<AllowedType>
|
||||
*/
|
||||
class StrictQueue extends StrictList implements ArrayAccess, Countable, Iterator, Serializable
|
||||
class StrictQueue extends SplQueue
|
||||
{
|
||||
/**
|
||||
* Dequeue an item from the queue.
|
||||
*
|
||||
* @return AllowedType The dequeued item
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function dequeue(): mixed
|
||||
{
|
||||
return parent::shift();
|
||||
}
|
||||
/** @use StrictSplDatastructureTrait<AllowedType> */
|
||||
use StrictSplDatastructureTrait;
|
||||
|
||||
/**
|
||||
* Add an item to the queue.
|
||||
|
@ -73,79 +54,12 @@ class StrictQueue extends StrictList implements ArrayAccess, Countable, Iterator
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if `$value` is not of allowed type
|
||||
* @throws InvalidDataTypeException if `$value` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function enqueue(mixed $value): void
|
||||
{
|
||||
parent::push($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mode of iteration.
|
||||
*
|
||||
* @param int $mode The new iterator mode (0 or 1)
|
||||
*
|
||||
* There are two orthogonal sets of modes that can be set.
|
||||
*
|
||||
* The direction of iteration (fixed for StrictQueue):
|
||||
* - StrictQueue::IT_MODE_FIFO (queue style)
|
||||
*
|
||||
* The behavior of the iterator (either one or the other):
|
||||
* - StrictQueue::IT_MODE_DELETE (delete items)
|
||||
* - StrictQueue::IT_MODE_KEEP (keep items)
|
||||
*
|
||||
* The default mode is: IT_MODE_FIFO | IT_MODE_KEEP
|
||||
*
|
||||
* @return int The set of flags and modes of iteration
|
||||
*
|
||||
* @throws RangeException if an invalid `$mode` is given
|
||||
* @throws RuntimeException if trying to change iterator direction
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
final public function setIteratorMode(int $mode): int
|
||||
{
|
||||
if ($mode > 1) {
|
||||
throw new RuntimeException(
|
||||
sprintf(
|
||||
'Changing the iterator direction of %s is prohibited.',
|
||||
static::class
|
||||
)
|
||||
);
|
||||
}
|
||||
return parent::setIteratorMode($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a type-sensitive, traversable queue 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 = [])
|
||||
{
|
||||
parent::__construct($allowedTypes);
|
||||
$this->setIteratorMode(0);
|
||||
$this->push($value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,420 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
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 <sebastian.meyer@opencultureconsulting.com>
|
||||
* @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<int, AllowedType> $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<int, AllowedType> $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<int, AllowedType> Array of list items
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return iterator_to_array($this, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn list into a type-sensitive collection.
|
||||
*
|
||||
* @return StrictCollection<AllowedType> 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<int, AllowedType> $values */
|
||||
$values = $data['StrictSplDatastructure::dllist'];
|
||||
$this->append(...$values);
|
||||
/** @var int $flags */
|
||||
$flags = $data['StrictSplDatastructure::flags'];
|
||||
$this->setIteratorMode($flags);
|
||||
}
|
||||
}
|
|
@ -23,24 +23,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCC\Basics\DataStructures;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use InvalidArgumentException;
|
||||
use Iterator;
|
||||
use RangeException;
|
||||
use OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException;
|
||||
use OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait;
|
||||
use RuntimeException;
|
||||
use Serializable;
|
||||
|
||||
use function sprintf;
|
||||
use SplStack;
|
||||
|
||||
/**
|
||||
* A type-sensitive, taversable stack (LIFO).
|
||||
*
|
||||
* Extends [\SplDoublyLinkedList](https://www.php.net/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. It
|
||||
* also restricts the iterator direction to last-in, first-out (LIFO) exactly
|
||||
* like [\SplStack](https://www.php.net/splstack).
|
||||
* Extends [\SplStack](https://www.php.net/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.
|
||||
*
|
||||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\DataStructures
|
||||
|
@ -48,12 +41,13 @@ use function sprintf;
|
|||
* @api
|
||||
*
|
||||
* @template AllowedType of mixed
|
||||
* @extends StrictList<AllowedType>
|
||||
* @implements ArrayAccess<int, AllowedType>
|
||||
* @implements Iterator<AllowedType>
|
||||
* @extends SplStack<AllowedType>
|
||||
*/
|
||||
class StrictStack extends StrictList implements ArrayAccess, Countable, Iterator, Serializable
|
||||
class StrictStack extends SplStack
|
||||
{
|
||||
/** @use StrictSplDatastructureTrait<AllowedType> */
|
||||
use StrictSplDatastructureTrait;
|
||||
|
||||
/**
|
||||
* Add an item to the stack.
|
||||
*
|
||||
|
@ -61,13 +55,13 @@ class StrictStack extends StrictList implements ArrayAccess, Countable, Iterator
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if `$value` is not of allowed type
|
||||
* @throws InvalidDataTypeException if `$value` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function stack(mixed $value): void
|
||||
{
|
||||
parent::push($value);
|
||||
$this->push($value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,77 +69,12 @@ class StrictStack extends StrictList implements ArrayAccess, Countable, Iterator
|
|||
*
|
||||
* @return AllowedType The unstacked item
|
||||
*
|
||||
* @throws RuntimeException if the list is empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function unstack(): mixed
|
||||
{
|
||||
return parent::pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mode of iteration.
|
||||
*
|
||||
* @param int $mode The new iterator mode (2 or 3)
|
||||
*
|
||||
* There are two orthogonal sets of modes that can be set.
|
||||
*
|
||||
* The direction of iteration (fixed for StrictStack):
|
||||
* - StrictStack::IT_MODE_LIFO (stack style)
|
||||
*
|
||||
* The behavior of the iterator (either one or the other):
|
||||
* - StrictStack::IT_MODE_DELETE (delete items)
|
||||
* - StrictStack::IT_MODE_KEEP (keep items)
|
||||
*
|
||||
* The default mode is: IT_MODE_LIFO | IT_MODE_KEEP
|
||||
*
|
||||
* @return int The set of flags and modes of iteration
|
||||
*
|
||||
* @throws RangeException if an invalid `$mode` is given
|
||||
* @throws RuntimeException if trying to change iterator direction
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
final public function setIteratorMode(int $mode): int
|
||||
{
|
||||
if ($mode < 2) {
|
||||
throw new RuntimeException(
|
||||
sprintf(
|
||||
'Changing the iterator direction of %s is prohibited.',
|
||||
static::class
|
||||
)
|
||||
);
|
||||
}
|
||||
return parent::setIteratorMode($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a type-sensitive, traversable stack 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 = [])
|
||||
{
|
||||
parent::__construct($allowedTypes);
|
||||
$this->setIteratorMode(2);
|
||||
return $this->pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,422 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCC\Basics\DataStructures\Traits;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException;
|
||||
use OCC\Basics\DataStructures\StrictCollection;
|
||||
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 <sebastian.meyer@opencultureconsulting.com>
|
||||
* @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 InvalidDataTypeException 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 InvalidDataTypeException if any `$values` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function append(mixed ...$values): void
|
||||
{
|
||||
/** @var array<int, AllowedType> $values */
|
||||
foreach ($values as $count => $value) {
|
||||
if (!$this->hasAllowedType($value)) {
|
||||
throw new InvalidDataTypeException(
|
||||
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 InvalidDataTypeException 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 InvalidDataTypeException(
|
||||
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 InvalidDataTypeException if `$value` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function prepend(mixed ...$values): void
|
||||
{
|
||||
/** @var array<int, AllowedType> $values */
|
||||
foreach ($values as $count => $value) {
|
||||
if (!$this->hasAllowedType($value)) {
|
||||
throw new InvalidDataTypeException(
|
||||
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 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)
|
||||
)
|
||||
);
|
||||
}
|
||||
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 InvalidDataTypeException 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<int, AllowedType> Array of list items
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return iterator_to_array($this, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn list into a type-sensitive collection.
|
||||
*
|
||||
* @return StrictCollection<AllowedType> 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 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)
|
||||
)
|
||||
);
|
||||
}
|
||||
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<int, AllowedType> $values */
|
||||
$values = $data['StrictSplDatastructure::dllist'];
|
||||
$this->append(...$values);
|
||||
/** @var int $flags */
|
||||
$flags = $data['StrictSplDatastructure::flags'];
|
||||
$this->setIteratorMode($flags);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCC\Basics\Traits;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
use function array_map;
|
||||
use function array_sum;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function function_exists;
|
||||
use function in_array;
|
||||
use function is_a;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_callable;
|
||||
use function is_countable;
|
||||
use function is_double;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
use function is_integer;
|
||||
use function is_iterable;
|
||||
use function is_long;
|
||||
use function is_null;
|
||||
use function is_numeric;
|
||||
use function is_resource;
|
||||
use function is_scalar;
|
||||
use function is_string;
|
||||
use function is_object;
|
||||
use function ltrim;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\Traits
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
trait TypeChecker
|
||||
{
|
||||
/**
|
||||
* The allowed data types.
|
||||
*
|
||||
* @var string[]
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected array $_allowedTypes = [];
|
||||
|
||||
/**
|
||||
* Get allowed data types.
|
||||
*
|
||||
* @return string[] The list of allowed data types
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getAllowedTypes(): array
|
||||
{
|
||||
return $this->_allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a value's data type is allowed.
|
||||
*
|
||||
* @param mixed $value The value to check
|
||||
*
|
||||
* @return bool Whether the value's data type is allowed
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function hasAllowedType(mixed $value): bool
|
||||
{
|
||||
if (count($this->getAllowedTypes()) === 0) {
|
||||
return true;
|
||||
}
|
||||
foreach ($this->getAllowedTypes() as $type) {
|
||||
$function = 'is_' . $type;
|
||||
if (function_exists($function) && $function($value)) {
|
||||
return true;
|
||||
}
|
||||
/** @var class-string $fqcn */
|
||||
$fqcn = ltrim($type, '\\');
|
||||
if (is_object($value) && is_a($value, $fqcn)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a data type is allowed.
|
||||
*
|
||||
* @param string $type The type to check
|
||||
*
|
||||
* @return bool Whether the data type is allowed
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isAllowedType(string $type): bool
|
||||
{
|
||||
return in_array($type, $this->getAllowedTypes(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set allowed data types.
|
||||
*
|
||||
* @param string[] $allowedTypes Allowed data types
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if any value of `$allowedTypes` is not a string
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setAllowedTypes(array $allowedTypes = []): void
|
||||
{
|
||||
if (array_sum(array_map('is_string', $allowedTypes)) !== count($allowedTypes)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Allowed types must be array of strings or empty array.'
|
||||
);
|
||||
}
|
||||
$this->_allowedTypes = array_values($allowedTypes);
|
||||
}
|
||||
}
|
|
@ -64,6 +64,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -77,6 +77,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -153,7 +171,12 @@
|
|||
<div class="section" id="changelog">
|
||||
<h1>Changelog</h1>
|
||||
|
||||
<div class="contents"><ul class="phpdocumentor-list"><li class="toc-item"><a href="guides/changelog.html#v2-0-0">v2.0.0</a></li><li class="toc-item"><a href="guides/changelog.html#v1-1-0">v1.1.0</a></li><li class="toc-item"><a href="guides/changelog.html#v1-0-1">v1.0.1</a></li><li class="toc-item"><a href="guides/changelog.html#v1-0-0">v1.0.0</a></li></ul></div>
|
||||
<div class="admonition-wrapper">
|
||||
<div class="admonition admonition-sidebar"><p class="sidebar-title">Table of Contents</p>
|
||||
<div class="contents"><ul class="phpdocumentor-list"><li class="toc-item"><a href="guides/changelog.html#v2-0-0">v2.0.0</a></li><li class="toc-item"><a href="guides/changelog.html#v1-1-0">v1.1.0</a></li><li class="toc-item"><a href="guides/changelog.html#v1-0-1">v1.0.1</a></li><li class="toc-item"><a href="guides/changelog.html#v1-0-0">v1.0.0</a></li></ul></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section" id="v2-0-0">
|
||||
<h2>v2.0.0</h2>
|
||||
|
||||
|
@ -197,7 +220,14 @@ function _magicSet{PascalCasePropertyName}(mixed $value): void</code></pre></li>
|
|||
<li>Added new trait <a href="classes/OCC-Basics-Traits-OverloadingSetter.html"><abbr title="\OCC\Basics\Traits\OverloadingSetter">OverloadingSetter</abbr></a>
|
||||
</li>
|
||||
|
||||
<li>Extended API for all datastructures</li>
|
||||
<li>Added new trait <a href="classes/OCC-Basics-Traits-TypeChecker.html"><abbr title="\OCC\Basics\Traits\TypeChecker">TypeChecker</abbr></a>
|
||||
</li>
|
||||
|
||||
<li>Extended API for all datastructures (see <a href="classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html"><abbr title="\OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait">StrictSplDatastructureTrait</abbr></a>
|
||||
)</li>
|
||||
|
||||
<li>Introduced <a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html"><abbr title="\OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException">InvalidDataTypeException</abbr></a>
|
||||
for strict datastructures</li>
|
||||
|
||||
<li>Extended <a href="https://opencultureconsulting.github.io/php-basics/">documentation</a></li>
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="layout" content="landingpage" />
|
||||
<title>PHP Basics</title>
|
||||
<title>PHP Basics</title>
|
||||
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
@ -78,6 +77,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -154,7 +171,40 @@
|
|||
<div class="section" id="documentation">
|
||||
<h1>Documentation</h1>
|
||||
|
||||
|
||||
<div class="toc">
|
||||
<ul class="phpdocumentor-list">
|
||||
<li class="toc-item"><a href="guides/overview/index.html#overview">Overview</a> <ul class="menu-level-1">
|
||||
<li class="toc-item"><a href="guides/overview/datastructures.html#typed-datastructures">Typed Datastructures</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/errorhandlers.html#error-and-exception-handlers">Error and Exception Handlers</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/interfaces.html#interface-traits">Interface Traits</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/traits.html#traits">Traits</a></li>
|
||||
|
||||
</ul></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/usage/index.html#user-guide">User Guide</a> <ul class="menu-level-1">
|
||||
<li class="toc-item"><a href="guides/usage/requirements.html#requirements">Requirements</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/usage/installation.html#installation">Installation</a></li>
|
||||
|
||||
</ul></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/changelog.html#changelog">Changelog</a> <ul class="section-level-1">
|
||||
<li class="toc-item"><a href="guides/changelog.html#v2-0-0">v2.0.0</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/changelog.html#v1-1-0">v1.1.0</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/changelog.html#v1-0-1">v1.0.1</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/changelog.html#v1-0-0">v1.0.0</a></li>
|
||||
|
||||
</ul></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,289 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<div class="section" id="typed-datastructures">
|
||||
<h1>Typed Datastructures</h1>
|
||||
|
||||
<div class="admonition-wrapper">
|
||||
<div class="admonition admonition-sidebar"><p class="sidebar-title">Table of Contents</p>
|
||||
<div class="contents"><ul class="phpdocumentor-list"><li class="toc-item"><a href="guides/overview/datastructures.html#strictcollection">StrictCollection</a></li><li class="toc-item"><a href="guides/overview/datastructures.html#strictlist">StrictList</a></li><li class="toc-item"><a href="guides/overview/datastructures.html#strictqueue">StrictQueue</a></li><li class="toc-item"><a href="guides/overview/datastructures.html#strictstack">StrictStack</a></li></ul></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>All datastructures in this package have in common that you can control the types of items they can hold.</p>
|
||||
<p>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 <code>array</code>, <code>bool</code>, <code>callable</code>, <code>countable</code>,
|
||||
<code>float</code> / <code>double</code>, <code>int</code> / <code>integer</code> / <code>long</code>, <code>iterable</code>, <code>null</code>, <code>numeric</code>, <code>object</code>, <code>resource</code>, <code>scalar</code> and
|
||||
<code>string</code>.</p>
|
||||
<p>Trying to add an item with a data type not on the list of allowed types to a strict datastructure will result in an
|
||||
<a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html"><abbr title="\OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException">InvalidDataTypeException</abbr></a>
|
||||
.</p>
|
||||
<blockquote><p>Examples:</p><pre><code class="language-php">// create a collection of strings
|
||||
$stringCollection = new StrictCollection(['string']);
|
||||
|
||||
// create a queue of PSR-15 middlewares
|
||||
$middlewareQueue = new StrictQueue(['Psr\Http\Server\MiddlewareInterface']);</code></pre></blockquote>
|
||||
|
||||
<div class="section" id="strictcollection">
|
||||
<h2>StrictCollection</h2>
|
||||
|
||||
<div class="admonition-wrapper">
|
||||
<div class="admonition admonition-sidebar"><p class="sidebar-title">API Documentation</p>
|
||||
<p><a href="classes/OCC-Basics-DataStructures-StrictCollection.html"><abbr title="\OCC\Basics\DataStructures\StrictCollection">StrictCollection</abbr></a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p><em>A type-sensitive, unsorted collection of items.</em></p>
|
||||
<p>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.</p>
|
||||
<p>A <code>StrictCollection</code> can be accessed like an array, but not traversed because it has no particular order. Technically
|
||||
speaking, <code>StrictCollection</code> implements <a href="https://www.php.net/arrayaccess">\ArrayAccess</a>, <a href="https://www.php.net/countable">\Countable</a> and <a href="https://www.php.net/serializable">\Serializable</a>, but no <a href="https://www.php.net/traversable">\Traversable</a> interface.</p>
|
||||
<div class="phpdocumentor-admonition note">
|
||||
<svg class="phpdocumentor-admonition__icon" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"></path></svg>
|
||||
<article>
|
||||
<p>Internally it holds the items in the <code>$_data</code> array, the same as most <a href="namespaces/occ-basics-interfaces.html"><abbr title="\OCC\Basics\Interfaces">Interfaces</abbr></a>
|
||||
and
|
||||
<a href="namespaces/occ-basics-traits.html"><abbr title="\OCC\Basics\Traits">Traits</abbr></a>
|
||||
of this package.</p>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="section" id="strictlist">
|
||||
<h2>StrictList</h2>
|
||||
|
||||
<div class="admonition-wrapper">
|
||||
<div class="admonition admonition-sidebar"><p class="sidebar-title">API Documentation</p>
|
||||
<p><a href="classes/OCC-Basics-DataStructures-StrictList.html"><abbr title="\OCC\Basics\DataStructures\StrictList">StrictList</abbr></a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p><em>A type-sensitive, taversable list of items.</em></p>
|
||||
<p>Extends <a href="https://www.php.net/spldoublylinkedlist">\SplDoublyLinkedList</a> with an option to restrict the allowed data
|
||||
types for list items.</p>
|
||||
</div>
|
||||
|
||||
<div class="section" id="strictqueue">
|
||||
<h2>StrictQueue</h2>
|
||||
|
||||
<div class="admonition-wrapper">
|
||||
<div class="admonition admonition-sidebar"><p class="sidebar-title">API Documentation</p>
|
||||
<p><a href="classes/OCC-Basics-DataStructures-StrictQueue.html"><abbr title="\OCC\Basics\DataStructures\StrictQueue">StrictQueue</abbr></a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p><em>A type-sensitive, taversable queue (FIFO) of items.</em></p>
|
||||
<p>Extends <a href="https://www.php.net/spldoublylinkedlist">\SplDoublyLinkedList</a> with an option to restrict the allowed data
|
||||
types for list items.</p>
|
||||
</div>
|
||||
|
||||
<div class="section" id="strictstack">
|
||||
<h2>StrictStack</h2>
|
||||
|
||||
<div class="admonition-wrapper">
|
||||
<div class="admonition admonition-sidebar"><p class="sidebar-title">API Documentation</p>
|
||||
<p><a href="classes/OCC-Basics-DataStructures-StrictStack.html"><abbr title="\OCC\Basics\DataStructures\StrictStack">StrictStack</abbr></a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p><em>A type-sensitive, taversable stack (LIFO) of items.</em></p>
|
||||
<p>Extends <a href="https://www.php.net/spldoublylinkedlist">\SplDoublyLinkedList</a> with an option to restrict the allowed data
|
||||
types for list items.</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="guides/overview/datastructures.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,225 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<div class="section" id="error-and-exception-handlers">
|
||||
<h1>Error and Exception Handlers</h1>
|
||||
|
||||
<div class="admonition-wrapper">
|
||||
<div class="admonition admonition-sidebar"><p class="sidebar-title">Table of Contents</p>
|
||||
<div class="contents"><ul class="phpdocumentor-list"><li class="toc-item"><a href="guides/overview/errorhandlers.html#throwerrorexception">ThrowErrorException</a></li><li class="toc-item"><a href="guides/overview/errorhandlers.html#triggerexceptionerror">TriggerExceptionError</a></li></ul></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section" id="throwerrorexception">
|
||||
<h2>ThrowErrorException</h2>
|
||||
|
||||
<p>Throws internal errors as exceptions.</p>
|
||||
<p>If registered as error handler, this converts an internal PHP error into an
|
||||
<code>ErrorException</code>. It respects the <code>error_reporting</code> directive.</p>
|
||||
<p>> Usage: <code>set_error_handler(new ThrowErrorException());</code></p>
|
||||
</div>
|
||||
|
||||
<div class="section" id="triggerexceptionerror">
|
||||
<h2>TriggerExceptionError</h2>
|
||||
|
||||
<p>Triggers errors for uncaught exceptions.</p>
|
||||
<p>If registered as exception handler, this catches an uncaught exception and
|
||||
converts it into an internal PHP error of severity <code>E_USER_ERROR</code>.</p>
|
||||
<p>> Usage: <code>set_exception_handler(new TriggerExceptionError());</code></p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="guides/overview/errorhandlers.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -77,6 +77,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -153,6 +171,64 @@
|
|||
<div class="section" id="overview">
|
||||
<h1>Overview</h1>
|
||||
|
||||
<p>The package currently contains classes for <a href="guides/overview/datastructures.html">Typed Datastructures</a>
|
||||
, <a href="guides/overview/errorhandlers.html">Error and Exception Handlers</a>
|
||||
, multiple <a href="guides/overview/interfaces.html">Interface Traits</a>
|
||||
, and
|
||||
more generic <a href="guides/overview/traits.html">Traits</a>
|
||||
for common use cases. They share the same design principles like property and method naming
|
||||
schema, the highest coding standards of <a href="https://phpstan.org/">PHPStan</a> and <a href="https://psalm.dev/">Psalm</a>, and full
|
||||
<a href="https://www.php-fig.org/psr/psr-12/">PSR-12</a> compliance to make sure they can be combined and easily re-used in
|
||||
other projects.</p>
|
||||
<div class="toc">
|
||||
<ul class="phpdocumentor-list">
|
||||
<li class="toc-item"><a href="guides/overview/datastructures.html#typed-datastructures">Typed Datastructures</a> <ul class="section-level-1">
|
||||
<li class="toc-item"><a href="guides/overview/datastructures.html#strictcollection">StrictCollection</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/datastructures.html#strictlist">StrictList</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/datastructures.html#strictqueue">StrictQueue</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/datastructures.html#strictstack">StrictStack</a></li>
|
||||
|
||||
</ul></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/errorhandlers.html#error-and-exception-handlers">Error and Exception Handlers</a> <ul class="section-level-1">
|
||||
<li class="toc-item"><a href="guides/overview/errorhandlers.html#throwerrorexception">ThrowErrorException</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/errorhandlers.html#triggerexceptionerror">TriggerExceptionError</a></li>
|
||||
|
||||
</ul></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/interfaces.html#interface-traits">Interface Traits</a> <ul class="section-level-1">
|
||||
<li class="toc-item"><a href="guides/overview/interfaces.html#arrayaccesstrait">ArrayAccessTrait</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/interfaces.html#countabletrait">CountableTrait</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/interfaces.html#iteratoraggregatetrait">IteratorAggregateTrait</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/interfaces.html#iteratortrait">IteratorTrait</a></li>
|
||||
|
||||
</ul></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/traits.html#traits">Traits</a> <ul class="section-level-1">
|
||||
<li class="toc-item"><a href="guides/overview/traits.html#getter">Getter</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/traits.html#overloadinggetter">OverloadingGetter</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/traits.html#overloadingsetter">OverloadingSetter</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/traits.html#setter">Setter</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/traits.html#singleton">Singleton</a></li>
|
||||
|
||||
<li class="toc-item"><a href="guides/overview/traits.html#typechecker">TypeChecker</a></li>
|
||||
|
||||
</ul></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,235 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<div class="section" id="interface-traits">
|
||||
<h1>Interface Traits</h1>
|
||||
|
||||
<div class="admonition-wrapper">
|
||||
<div class="admonition admonition-sidebar"><p class="sidebar-title">Table of Contents</p>
|
||||
<div class="contents"><ul class="phpdocumentor-list"><li class="toc-item"><a href="guides/overview/interfaces.html#arrayaccesstrait">ArrayAccessTrait</a></li><li class="toc-item"><a href="guides/overview/interfaces.html#countabletrait">CountableTrait</a></li><li class="toc-item"><a href="guides/overview/interfaces.html#iteratoraggregatetrait">IteratorAggregateTrait</a></li><li class="toc-item"><a href="guides/overview/interfaces.html#iteratortrait">IteratorTrait</a></li></ul></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section" id="arrayaccesstrait">
|
||||
<h2>ArrayAccessTrait</h2>
|
||||
|
||||
<p>A generic implementation of the ArrayAccess interface.</p>
|
||||
<p>Internally it accesses the protected <code>$_data</code> array.</p>
|
||||
</div>
|
||||
|
||||
<div class="section" id="countabletrait">
|
||||
<h2>CountableTrait</h2>
|
||||
|
||||
<p>A generic implementation of the Countable interface.</p>
|
||||
<p>Internally it counts the values of the protected <code>$_data</code> array.</p>
|
||||
</div>
|
||||
|
||||
<div class="section" id="iteratoraggregatetrait">
|
||||
<h2>IteratorAggregateTrait</h2>
|
||||
|
||||
<p>A generic implementation of the IteratorAggregate interface.</p>
|
||||
<p>Internally it iterates over the protected <code>$_data</code> array.</p>
|
||||
</div>
|
||||
|
||||
<div class="section" id="iteratortrait">
|
||||
<h2>IteratorTrait</h2>
|
||||
|
||||
<p>A generic implementation of the Iterator interface.</p>
|
||||
<p>Internally it iterates over the protected <code>$_data</code> array.</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="guides/overview/interfaces.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,272 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<div class="section" id="traits">
|
||||
<h1>Traits</h1>
|
||||
|
||||
<div class="admonition-wrapper">
|
||||
<div class="admonition admonition-sidebar"><p class="sidebar-title">Table of Contents</p>
|
||||
<div class="contents"><ul class="phpdocumentor-list"><li class="toc-item"><a href="guides/overview/traits.html#getter">Getter</a></li><li class="toc-item"><a href="guides/overview/traits.html#overloadinggetter">OverloadingGetter</a></li><li class="toc-item"><a href="guides/overview/traits.html#overloadingsetter">OverloadingSetter</a></li><li class="toc-item"><a href="guides/overview/traits.html#setter">Setter</a></li><li class="toc-item"><a href="guides/overview/traits.html#singleton">Singleton</a></li><li class="toc-item"><a href="guides/overview/traits.html#typechecker">TypeChecker</a></li></ul></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section" id="getter">
|
||||
<h2>Getter</h2>
|
||||
|
||||
<p>Reads data from inaccessible properties by using magic methods.</p>
|
||||
<p>To make a <code>protected</code> or <code>private</code> property readable, provide a method named
|
||||
<code>_magicGet{Property}()</code> which handles the reading. Replace <code>{Property}</code> in
|
||||
the method's name with the name of the actual property (with an uppercase
|
||||
first letter).</p>
|
||||
<p>> Example: If the property is named <code>$fooBar</code>, the "magic" method has to be
|
||||
> <code>_magicGetFooBar()</code>. This method is then called when <code>$fooBar</code> is read in
|
||||
> a context where it normally would not be accessible.</p>
|
||||
</div>
|
||||
|
||||
<div class="section" id="overloadinggetter">
|
||||
<h2>OverloadingGetter</h2>
|
||||
|
||||
<p>Overloads a class with readable magic properties.</p>
|
||||
<p>Internally it reads the protected <code>$_data</code> array whose keys are interpreted
|
||||
as property names.</p>
|
||||
<p>> Example: Reading <code>Foo->bar</code> will return the value of <code>$_data['bar']</code>.</p>
|
||||
</div>
|
||||
|
||||
<div class="section" id="overloadingsetter">
|
||||
<h2>OverloadingSetter</h2>
|
||||
|
||||
<p>Overloads a class with writable magic properties.</p>
|
||||
<p>Internally it writes the protected <code>$_data</code> array whose keys are interpreted
|
||||
as property names.</p>
|
||||
<p>> Example: <code>Foo->bar = 42;</code> will set <code>$_data['bar']</code> to <code>42</code>.</p>
|
||||
</div>
|
||||
|
||||
<div class="section" id="setter">
|
||||
<h2>Setter</h2>
|
||||
|
||||
<p>Writes data to inaccessible properties by using magic methods.</p>
|
||||
<p>To make a <code>protected</code> or <code>private</code> property writable, provide a method named
|
||||
<code>_magicSet{Property}()</code> which handles the writing. Replace <code>{Property}</code> in
|
||||
the method's name with the name of the actual property (with an uppercase
|
||||
first letter).</p>
|
||||
<p>> Example: If the property is named <code>$fooBar</code>, the "magic" method has to be
|
||||
> <code>_magicSetFooBar()</code>. This method is then called when <code>$fooBar</code> is written
|
||||
> to in a context where it normally would not be accessible.</p>
|
||||
</div>
|
||||
|
||||
<div class="section" id="singleton">
|
||||
<h2>Singleton</h2>
|
||||
|
||||
<p>Allows just a single instance of the class using this trait.</p>
|
||||
<p>Get the singleton by calling the static method <code>getInstance()</code>.</p>
|
||||
<p>If there is no object yet, the constructor is called with the same arguments
|
||||
as <code>getInstance()</code>. Any later call will just return the already instantiated
|
||||
object (irrespective of the given arguments).</p>
|
||||
<p>In order for this to work as expected, the constructor has to be implemented
|
||||
as <code>private</code> to prevent direct instantiation of the class.</p>
|
||||
</div>
|
||||
|
||||
<div class="section" id="typechecker">
|
||||
<h2>TypeChecker</h2>
|
||||
|
||||
<p>A generic data type checker.</p>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="guides/overview/traits.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -77,6 +77,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -153,6 +171,10 @@
|
|||
<div class="section" id="user-guide">
|
||||
<h1>User Guide</h1>
|
||||
|
||||
<p>The <em>PHP Basics</em> 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 <a href="guides/overview/index.html">Overview</a>
|
||||
page.</p>
|
||||
<div class="toc">
|
||||
<ul class="phpdocumentor-list">
|
||||
<li class="toc-item"><a href="guides/usage/requirements.html#requirements">Requirements</a> <ul class="section-level-1">
|
||||
|
|
|
@ -77,6 +77,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -153,6 +171,12 @@
|
|||
<div class="section" id="installation">
|
||||
<h1>Installation</h1>
|
||||
|
||||
<div class="admonition-wrapper">
|
||||
<div class="admonition admonition-sidebar"><p class="sidebar-title">Table of Contents</p>
|
||||
<div class="contents"><ul class="phpdocumentor-list"><li class="toc-item"><a href="guides/usage/installation.html#composer">Composer</a></li><li class="toc-item"><a href="guides/usage/installation.html#git">Git</a></li><li class="toc-item"><a href="guides/usage/installation.html#download">Download</a></li></ul></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section" id="composer">
|
||||
<h2>Composer</h2>
|
||||
|
||||
|
|
|
@ -77,6 +77,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -158,10 +176,10 @@
|
|||
|
||||
<p class="phpdocumentor-summary">A collection of generic classes and useful traits for PHP projects.</p>
|
||||
|
||||
<p>The package currently contains classes for <a href="packages/Basics-DataStructures.html">type-sensitive
|
||||
data structures</a>, <a href="packages/Basics-ErrorHandlers.html">error and exception handlers</a>, multiple
|
||||
<a href="packages/Basics-Interfaces.html">traits implementing standard interfaces</a>, and more generic
|
||||
<a href="packages/Basics-Traits.html">traits for common use cases</a>. They share the same design principles
|
||||
<p>The package currently contains classes for <a href="guides/overview/datastructures.html">type-sensitive
|
||||
data structures</a>, <a href="guides/overview/errorhandlers.html">error and exception handlers</a>, multiple
|
||||
<a href="guides/overview/interfaces.html">traits implementing standard interfaces</a>, and more generic
|
||||
<a href="guides/overview/traits.html">traits for common use cases</a>. They share the same design principles
|
||||
like property and method naming schema, highest coding standards of <a href="https://phpstan.org/">PHPStan</a>
|
||||
and <a href="https://psalm.dev/">Psalm</a>, and full <a href="https://www.php-fig.org/psr/psr-12/">PSR-12</a>
|
||||
compliance to make sure they can be combined and easily re-used in other projects.</p>
|
||||
|
@ -173,6 +191,12 @@
|
|||
<dt class="phpdocumentor-table-of-contents__entry -documentation">
|
||||
<a href="guides/overview/index.html#overview">Overview</a>
|
||||
</dt>
|
||||
<dd>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures">Typed Datastructures</a><br/>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers">Error and Exception Handlers</a><br/>
|
||||
<a href="guides/overview/interfaces.html#interface-traits">Interface Traits</a><br/>
|
||||
<a href="guides/overview/traits.html#traits">Traits</a><br/>
|
||||
</dd>
|
||||
<dt class="phpdocumentor-table-of-contents__entry -documentation">
|
||||
<a href="guides/usage/index.html#user-guide">User Guide</a>
|
||||
</dt>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -166,6 +184,7 @@
|
|||
</ul>
|
||||
<h3>I</h3>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li><a href="files/src-datastructures-exceptions-invaliddatatypeexception.html"><abbr title="src/DataStructures/Exceptions/InvalidDataTypeException.php">InvalidDataTypeException.php</abbr></a></li>
|
||||
<li><a href="files/src-interfaces-iteratoraggregatetrait.html"><abbr title="src/Interfaces/IteratorAggregateTrait.php">IteratorAggregateTrait.php</abbr></a></li>
|
||||
<li><a href="files/src-interfaces-iteratortrait.html"><abbr title="src/Interfaces/IteratorTrait.php">IteratorTrait.php</abbr></a></li>
|
||||
</ul>
|
||||
|
@ -181,12 +200,14 @@
|
|||
<li><a href="files/src-datastructures-strictcollection.html"><abbr title="src/DataStructures/StrictCollection.php">StrictCollection.php</abbr></a></li>
|
||||
<li><a href="files/src-datastructures-strictlist.html"><abbr title="src/DataStructures/StrictList.php">StrictList.php</abbr></a></li>
|
||||
<li><a href="files/src-datastructures-strictqueue.html"><abbr title="src/DataStructures/StrictQueue.php">StrictQueue.php</abbr></a></li>
|
||||
<li><a href="files/src-datastructures-traits-strictspldatastructuretrait.html"><abbr title="src/DataStructures/Traits/StrictSplDatastructureTrait.php">StrictSplDatastructureTrait.php</abbr></a></li>
|
||||
<li><a href="files/src-datastructures-strictstack.html"><abbr title="src/DataStructures/StrictStack.php">StrictStack.php</abbr></a></li>
|
||||
</ul>
|
||||
<h3>T</h3>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li><a href="files/src-errorhandlers-throwerrorexception.html"><abbr title="src/ErrorHandlers/ThrowErrorException.php">ThrowErrorException.php</abbr></a></li>
|
||||
<li><a href="files/src-errorhandlers-triggerexceptionerror.html"><abbr title="src/ErrorHandlers/TriggerExceptionError.php">TriggerExceptionError.php</abbr></a></li>
|
||||
<li><a href="files/src-traits-typechecker.html"><abbr title="src/Traits/TypeChecker.php">TypeChecker.php</abbr></a></li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
Search.appendIndex(
|
||||
[
|
||||
{
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Exceptions\\InvalidDataTypeException",
|
||||
"name": "InvalidDataTypeException",
|
||||
"summary": "Common\u0020exception\u0020for\u0020type\u002Dsensitive\u0020datastructures.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictCollection",
|
||||
"name": "StrictCollection",
|
||||
"summary": "A\u0020type\u002Dsensitive,\u0020unsorted\u0020collection.",
|
||||
|
@ -8,7 +13,7 @@ Search.appendIndex(
|
|||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictCollection\u003A\u003Aadd\u0028\u0029",
|
||||
"name": "add",
|
||||
"summary": "Add\/insert\u0020a\u0020new\u0020item\u0020at\u0020the\u0020specified\u0020index.",
|
||||
"summary": "Add\/insert\u0020a\u0020item\u0020at\u0020the\u0020specified\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictCollection.html#method_add"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictCollection\u003A\u003Aclear\u0028\u0029",
|
||||
|
@ -20,16 +25,6 @@ Search.appendIndex(
|
|||
"name": "get",
|
||||
"summary": "Get\u0020the\u0020item\u0020at\u0020the\u0020specified\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictCollection.html#method_get"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictCollection\u003A\u003AgetAllowedTypes\u0028\u0029",
|
||||
"name": "getAllowedTypes",
|
||||
"summary": "Get\u0020allowed\u0020data\u0020types\u0020for\u0020collection\u0020items.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictCollection.html#method_getAllowedTypes"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictCollection\u003A\u003AisAllowedType\u0028\u0029",
|
||||
"name": "isAllowedType",
|
||||
"summary": "Check\u0020if\u0020the\u0020item\u0027s\u0020data\u0020type\u0020is\u0020allowed\u0020in\u0020the\u0020collection.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictCollection.html#method_isAllowedType"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictCollection\u003A\u003AisEmpty\u0028\u0029",
|
||||
"name": "isEmpty",
|
||||
|
@ -60,11 +55,6 @@ Search.appendIndex(
|
|||
"name": "set",
|
||||
"summary": "Set\u0020an\u0020item\u0020at\u0020the\u0020specified\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictCollection.html#method_set"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictCollection\u003A\u003AsetAllowedTypes\u0028\u0029",
|
||||
"name": "setAllowedTypes",
|
||||
"summary": "Set\u0020allowed\u0020data\u0020types\u0020of\u0020collection\u0020items.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictCollection.html#method_setAllowedTypes"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictCollection\u003A\u003AtoArray\u0028\u0029",
|
||||
"name": "toArray",
|
||||
|
@ -90,201 +80,16 @@ Search.appendIndex(
|
|||
"name": "StrictList",
|
||||
"summary": "A\u0020type\u002Dsensitive,\u0020taversable\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Aadd\u0028\u0029",
|
||||
"name": "add",
|
||||
"summary": "Add\/insert\u0020a\u0020new\u0020item\u0020at\u0020the\u0020specified\u0020offset.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_add"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Aappend\u0028\u0029",
|
||||
"name": "append",
|
||||
"summary": "Append\u0020items\u0020at\u0020the\u0020end\u0020of\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_append"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Abottom\u0028\u0029",
|
||||
"name": "bottom",
|
||||
"summary": "Peek\u0020at\u0020the\u0020item\u0020at\u0020the\u0020beginning\u0020of\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_bottom"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Aclear\u0028\u0029",
|
||||
"name": "clear",
|
||||
"summary": "Clear\u0020the\u0020list\u0020of\u0020any\u0020items.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_clear"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Acount\u0028\u0029",
|
||||
"name": "count",
|
||||
"summary": "Get\u0020the\u0020number\u0020of\u0020items\u0020on\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_count"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Acurrent\u0028\u0029",
|
||||
"name": "current",
|
||||
"summary": "Get\u0020the\u0020current\u0020list\u0020item.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_current"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Aget\u0028\u0029",
|
||||
"name": "get",
|
||||
"summary": "Get\u0020the\u0020item\u0020at\u0020the\u0020specified\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_get"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AgetAllowedTypes\u0028\u0029",
|
||||
"name": "getAllowedTypes",
|
||||
"summary": "Get\u0020allowed\u0020data\u0020types\u0020for\u0020list\u0020items.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_getAllowedTypes"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AgetIteratorMode\u0028\u0029",
|
||||
"name": "getIteratorMode",
|
||||
"summary": "Get\u0020the\u0020mode\u0020of\u0020iteration.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_getIteratorMode"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AisAllowedType\u0028\u0029",
|
||||
"name": "isAllowedType",
|
||||
"summary": "Check\u0020if\u0020the\u0020item\u0027s\u0020data\u0020type\u0020is\u0020allowed\u0020on\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_isAllowedType"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AisEmpty\u0028\u0029",
|
||||
"name": "isEmpty",
|
||||
"summary": "Check\u0020if\u0020list\u0020is\u0020empty.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_isEmpty"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AisList\u0028\u0029",
|
||||
"name": "isList",
|
||||
"summary": "Check\u0020if\u0020this\u0020can\u0020be\u0020considered\u0020a\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_isList"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Akey\u0028\u0029",
|
||||
"name": "key",
|
||||
"summary": "Get\u0020the\u0020current\u0020list\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_key"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Anext\u0028\u0029",
|
||||
"name": "next",
|
||||
"summary": "Move\u0020the\u0020cursor\u0020to\u0020the\u0020next\u0020list\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_next"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AoffsetExists\u0028\u0029",
|
||||
"name": "offsetExists",
|
||||
"summary": "Check\u0020if\u0020the\u0020specified\u0020index\u0020exists\u0020and\u0020is\u0020not\u0020empty.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_offsetExists"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AoffsetGet\u0028\u0029",
|
||||
"name": "offsetGet",
|
||||
"summary": "Get\u0020the\u0020item\u0020from\u0020the\u0020specified\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_offsetGet"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AoffsetSet\u0028\u0029",
|
||||
"name": "offsetSet",
|
||||
"summary": "Set\u0020the\u0020item\u0020at\u0020the\u0020specified\u0020offset.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_offsetSet"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AoffsetUnset\u0028\u0029",
|
||||
"name": "offsetUnset",
|
||||
"summary": "Unset\u0020the\u0020item\u0020at\u0020the\u0020specified\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_offsetUnset"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Apop\u0028\u0029",
|
||||
"name": "pop",
|
||||
"summary": "Pops\u0020an\u0020item\u0020from\u0020the\u0020end\u0020of\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_pop"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Aprepend\u0028\u0029",
|
||||
"name": "prepend",
|
||||
"summary": "Prepend\u0020items\u0020at\u0020the\u0020start\u0020of\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_prepend"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Aprev\u0028\u0029",
|
||||
"name": "prev",
|
||||
"summary": "Move\u0020the\u0020cursor\u0020to\u0020the\u0020previous\u0020list\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_prev"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Apush\u0028\u0029",
|
||||
"name": "push",
|
||||
"summary": "Push\u0020an\u0020item\u0020at\u0020the\u0020end\u0020of\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_push"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Aremove\u0028\u0029",
|
||||
"name": "remove",
|
||||
"summary": "Remove\u0020an\u0020item\u0020from\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_remove"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Arewind\u0028\u0029",
|
||||
"name": "rewind",
|
||||
"summary": "Rewind\u0020the\u0020iterator\u0027s\u0020cursor.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_rewind"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Aset\u0028\u0029",
|
||||
"name": "set",
|
||||
"summary": "Set\u0020an\u0020item\u0020at\u0020the\u0020specified\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_set"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AsetAllowedTypes\u0028\u0029",
|
||||
"name": "setAllowedTypes",
|
||||
"summary": "Set\u0020allowed\u0020data\u0020types\u0020of\u0020list\u0020items.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_setAllowedTypes"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AsetIteratorMode\u0028\u0029",
|
||||
"name": "setIteratorMode",
|
||||
"summary": "Set\u0020the\u0020mode\u0020of\u0020iteration.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_setIteratorMode"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Ashift\u0028\u0029",
|
||||
"name": "shift",
|
||||
"summary": "Shift\u0020an\u0020item\u0020from\u0020the\u0020beginning\u0020of\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_shift"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AtoArray\u0028\u0029",
|
||||
"name": "toArray",
|
||||
"summary": "Return\u0020array\u0020representation\u0020of\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_toArray"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003AtoStrictCollection\u0028\u0029",
|
||||
"name": "toStrictCollection",
|
||||
"summary": "Turn\u0020list\u0020into\u0020a\u0020type\u002Dsensitive\u0020collection.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_toStrictCollection"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Atop\u0028\u0029",
|
||||
"name": "top",
|
||||
"summary": "Peek\u0020at\u0020the\u0020item\u0020at\u0020the\u0020end\u0020of\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_top"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Aunshift\u0028\u0029",
|
||||
"name": "unshift",
|
||||
"summary": "Prepend\u0020the\u0020list\u0020with\u0020an\u0020item.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_unshift"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003Avalid\u0028\u0029",
|
||||
"name": "valid",
|
||||
"summary": "Check\u0020if\u0020current\u0020cursor\u0020position\u0020is\u0020valid.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method_valid"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictList\u003A\u003A__construct\u0028\u0029",
|
||||
"name": "__construct",
|
||||
"summary": "Create\u0020a\u0020type\u002Dsensitive,\u0020traversable\u0020list\u0020of\u0020items.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictList.html#method___construct"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictQueue",
|
||||
"name": "StrictQueue",
|
||||
"summary": "A\u0020type\u002Dsensitive,\u0020taversable\u0020queue\u0020\u0028FIFO\u0029.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictQueue.html"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictQueue\u003A\u003Adequeue\u0028\u0029",
|
||||
"name": "dequeue",
|
||||
"summary": "Dequeue\u0020an\u0020item\u0020from\u0020the\u0020queue.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictQueue.html#method_dequeue"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictQueue\u003A\u003Aenqueue\u0028\u0029",
|
||||
"name": "enqueue",
|
||||
"summary": "Add\u0020an\u0020item\u0020to\u0020the\u0020queue.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictQueue.html#method_enqueue"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictQueue\u003A\u003AsetIteratorMode\u0028\u0029",
|
||||
"name": "setIteratorMode",
|
||||
"summary": "Set\u0020the\u0020mode\u0020of\u0020iteration.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictQueue.html#method_setIteratorMode"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictQueue\u003A\u003A__construct\u0028\u0029",
|
||||
"name": "__construct",
|
||||
"summary": "Create\u0020a\u0020type\u002Dsensitive,\u0020traversable\u0020queue\u0020of\u0020items.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictQueue.html#method___construct"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictStack",
|
||||
"name": "StrictStack",
|
||||
|
@ -301,15 +106,80 @@ Search.appendIndex(
|
|||
"summary": "Unstack\u0020an\u0020item\u0020from\u0020the\u0020stack.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictStack.html#method_unstack"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictStack\u003A\u003AsetIteratorMode\u0028\u0029",
|
||||
"name": "setIteratorMode",
|
||||
"summary": "Set\u0020the\u0020mode\u0020of\u0020iteration.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictStack.html#method_setIteratorMode"
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait",
|
||||
"name": "StrictSplDatastructureTrait",
|
||||
"summary": "The\u0020common\u0020interface\u0020of\u0020all\u0020type\u002Dsensitive,\u0020SPL\u002Dbased\u0020datastructures.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\StrictStack\u003A\u003A__construct\u0028\u0029",
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003Aadd\u0028\u0029",
|
||||
"name": "add",
|
||||
"summary": "Add\/insert\u0020a\u0020new\u0020item\u0020at\u0020the\u0020specified\u0020offset.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_add"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003Aappend\u0028\u0029",
|
||||
"name": "append",
|
||||
"summary": "Append\u0020items\u0020at\u0020the\u0020end\u0020of\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_append"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003Aclear\u0028\u0029",
|
||||
"name": "clear",
|
||||
"summary": "Clear\u0020the\u0020list\u0020of\u0020any\u0020items.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_clear"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003Aget\u0028\u0029",
|
||||
"name": "get",
|
||||
"summary": "Get\u0020the\u0020item\u0020at\u0020the\u0020specified\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_get"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003AisList\u0028\u0029",
|
||||
"name": "isList",
|
||||
"summary": "Check\u0020if\u0020this\u0020can\u0020be\u0020considered\u0020a\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_isList"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003AoffsetSet\u0028\u0029",
|
||||
"name": "offsetSet",
|
||||
"summary": "Set\u0020the\u0020item\u0020at\u0020the\u0020specified\u0020offset.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_offsetSet"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003Aprepend\u0028\u0029",
|
||||
"name": "prepend",
|
||||
"summary": "Prepend\u0020items\u0020at\u0020the\u0020start\u0020of\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_prepend"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003Apush\u0028\u0029",
|
||||
"name": "push",
|
||||
"summary": "Push\u0020an\u0020item\u0020at\u0020the\u0020end\u0020of\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_push"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003Aremove\u0028\u0029",
|
||||
"name": "remove",
|
||||
"summary": "Remove\u0020an\u0020item\u0020from\u0020the\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_remove"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003Aset\u0028\u0029",
|
||||
"name": "set",
|
||||
"summary": "Set\u0020an\u0020item\u0020at\u0020the\u0020specified\u0020index.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_set"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003AtoArray\u0028\u0029",
|
||||
"name": "toArray",
|
||||
"summary": "Return\u0020array\u0020representation\u0020of\u0020list.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_toArray"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003AtoStrictCollection\u0028\u0029",
|
||||
"name": "toStrictCollection",
|
||||
"summary": "Turn\u0020list\u0020into\u0020a\u0020type\u002Dsensitive\u0020collection.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_toStrictCollection"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003Aunshift\u0028\u0029",
|
||||
"name": "unshift",
|
||||
"summary": "Prepend\u0020the\u0020list\u0020with\u0020an\u0020item.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method_unshift"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits\\StrictSplDatastructureTrait\u003A\u003A__construct\u0028\u0029",
|
||||
"name": "__construct",
|
||||
"summary": "Create\u0020a\u0020type\u002Dsensitive,\u0020traversable\u0020stack\u0020of\u0020items.",
|
||||
"url": "classes/OCC-Basics-DataStructures-StrictStack.html#method___construct"
|
||||
"summary": "Create\u0020a\u0020type\u002Dsensitive,\u0020traversable\u0020list\u0020of\u0020items.",
|
||||
"url": "classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html#method___construct"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\ErrorHandlers\\ThrowErrorException",
|
||||
"name": "ThrowErrorException",
|
||||
|
@ -490,11 +360,41 @@ Search.appendIndex(
|
|||
"name": "__clone",
|
||||
"summary": "This\u0020is\u0020a\u0020singleton\u0020class,\u0020thus\u0020cloning\u0020is\u0020prohibited.",
|
||||
"url": "classes/OCC-Basics-Traits-Singleton.html#method___clone"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\Traits\\TypeChecker",
|
||||
"name": "TypeChecker",
|
||||
"summary": "A\u0020generic\u0020data\u0020type\u0020checker.",
|
||||
"url": "classes/OCC-Basics-Traits-TypeChecker.html"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\Traits\\TypeChecker\u003A\u003AgetAllowedTypes\u0028\u0029",
|
||||
"name": "getAllowedTypes",
|
||||
"summary": "Get\u0020allowed\u0020data\u0020types.",
|
||||
"url": "classes/OCC-Basics-Traits-TypeChecker.html#method_getAllowedTypes"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\Traits\\TypeChecker\u003A\u003AhasAllowedType\u0028\u0029",
|
||||
"name": "hasAllowedType",
|
||||
"summary": "Check\u0020if\u0020a\u0020value\u0027s\u0020data\u0020type\u0020is\u0020allowed.",
|
||||
"url": "classes/OCC-Basics-Traits-TypeChecker.html#method_hasAllowedType"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\Traits\\TypeChecker\u003A\u003AisAllowedType\u0028\u0029",
|
||||
"name": "isAllowedType",
|
||||
"summary": "Check\u0020if\u0020a\u0020data\u0020type\u0020is\u0020allowed.",
|
||||
"url": "classes/OCC-Basics-Traits-TypeChecker.html#method_isAllowedType"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\Traits\\TypeChecker\u003A\u003AsetAllowedTypes\u0028\u0029",
|
||||
"name": "setAllowedTypes",
|
||||
"summary": "Set\u0020allowed\u0020data\u0020types.",
|
||||
"url": "classes/OCC-Basics-Traits-TypeChecker.html#method_setAllowedTypes"
|
||||
}, {
|
||||
"fqsen": "\\",
|
||||
"name": "\\",
|
||||
"summary": "",
|
||||
"url": "namespaces/default.html"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Exceptions",
|
||||
"name": "Exceptions",
|
||||
"summary": "",
|
||||
"url": "namespaces/occ-basics-datastructures-exceptions.html"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures",
|
||||
"name": "DataStructures",
|
||||
|
@ -510,6 +410,11 @@ Search.appendIndex(
|
|||
"name": "OCC",
|
||||
"summary": "",
|
||||
"url": "namespaces/occ.html"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\DataStructures\\Traits",
|
||||
"name": "Traits",
|
||||
"summary": "",
|
||||
"url": "namespaces/occ-basics-datastructures-traits.html"
|
||||
}, {
|
||||
"fqsen": "\\OCC\\Basics\\ErrorHandlers",
|
||||
"name": "ErrorHandlers",
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -0,0 +1,345 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<section>
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ.html">OCC</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ-basics.html">Basics</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ-basics-datastructures.html">DataStructures</a></li>
|
||||
</ul>
|
||||
|
||||
<article class="phpdocumentor-element -namespace">
|
||||
<h2 class="phpdocumentor-content__title">Exceptions</h2>
|
||||
|
||||
|
||||
<h3 id="toc">
|
||||
Table of Contents
|
||||
<a href="namespaces/occ-basics-datastructures-exceptions.html#toc" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 id="toc-classes">
|
||||
Classes
|
||||
<a href="namespaces/occ-basics-datastructures-exceptions.html#toc-classes" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -class"><a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html"><abbr title="\OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException">InvalidDataTypeException</abbr></a></dt><dd>Common exception for type-sensitive datastructures.</dd> </dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="phpdocumentor-modal" id="source-view">
|
||||
<div class="phpdocumentor-modal-bg" data-exit-button></div>
|
||||
<div class="phpdocumentor-modal-container">
|
||||
<div class="phpdocumentor-modal-content">
|
||||
<pre style="max-height: 500px; overflow-y: scroll" data-src="" class="language-php line-numbers linkable-line-numbers"></pre>
|
||||
</div>
|
||||
<button data-exit-button class="phpdocumentor-modal__close">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
function loadExternalCodeSnippet(el, url, line) {
|
||||
Array.prototype.slice.call(el.querySelectorAll('pre[data-src]')).forEach((pre) => {
|
||||
const src = url || pre.getAttribute('data-src').replace(/\\/g, '/');
|
||||
const language = 'php';
|
||||
|
||||
const code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
pre.textContent = '';
|
||||
pre.setAttribute('data-line', line)
|
||||
code.textContent = 'Loading…';
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
Prism.highlightElement(code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status === 404) {
|
||||
code.textContent = '✖ Error: File could not be found';
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
return;
|
||||
}
|
||||
|
||||
code.textContent = '✖ Error: An unknown error occurred';
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
const modalButtons = document.querySelectorAll("[data-modal]");
|
||||
const openedAsLocalFile = window.location.protocol === 'file:';
|
||||
if (modalButtons.length > 0 && openedAsLocalFile) {
|
||||
console.warn(
|
||||
'Viewing the source code is unavailable because you are opening this page from the file:// scheme; ' +
|
||||
'browsers block XHR requests when a page is opened this way'
|
||||
);
|
||||
}
|
||||
|
||||
modalButtons.forEach(function (trigger) {
|
||||
if (openedAsLocalFile) {
|
||||
trigger.setAttribute("hidden", "hidden");
|
||||
}
|
||||
|
||||
trigger.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
const modal = document.getElementById(trigger.dataset.modal);
|
||||
if (!modal) {
|
||||
console.error(`Modal with id "${trigger.dataset.modal}" could not be found`);
|
||||
return;
|
||||
}
|
||||
modal.classList.add("phpdocumentor-modal__open");
|
||||
|
||||
loadExternalCodeSnippet(modal, trigger.dataset.src || null, trigger.dataset.line)
|
||||
const exits = modal.querySelectorAll("[data-exit-button]");
|
||||
exits.forEach(function (exit) {
|
||||
exit.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
modal.classList.remove("phpdocumentor-modal__open");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
</article>
|
||||
</section>
|
||||
<section class="phpdocumentor-on-this-page__sidebar">
|
||||
|
||||
<section class="phpdocumentor-on-this-page__content">
|
||||
<strong class="phpdocumentor-on-this-page__title">On this page</strong>
|
||||
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li class="phpdocumentor-on-this-page-section__title">Table Of Contents</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="namespaces/occ-basics-datastructures-exceptions.html#toc-classes">Classes</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="namespaces/occ-basics-datastructures-exceptions.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,345 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>PHP Basics</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="../">
|
||||
<link rel="icon" href="images/favicon.ico"/>
|
||||
<link rel="stylesheet" href="css/normalize.css">
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@100;200;300;400;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/template.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
|
||||
<script src="js/template.js"></script>
|
||||
<script src="js/search.js"></script>
|
||||
<script defer src="js/searchIndex.js"></script>
|
||||
</head>
|
||||
<body id="top">
|
||||
<header class="phpdocumentor-header phpdocumentor-section">
|
||||
<h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">PHP Basics</a></h1>
|
||||
<input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
|
||||
<label class="phpdocumentor-header__menu-icon" for="menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</label>
|
||||
<section data-search-form class="phpdocumentor-search">
|
||||
<label>
|
||||
<span class="visually-hidden">Search for</span>
|
||||
<svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
|
||||
<line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
<input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
|
||||
<nav class="phpdocumentor-topnav">
|
||||
<ul class="phpdocumentor-topnav__menu">
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://packagist.org/packages/opencultureconsulting/basics">
|
||||
<span>
|
||||
<i class="fab fa-php"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="phpdocumentor-topnav__menu-item -menu">
|
||||
<a href="https://github.com/opencultureconsulting/php-basics">
|
||||
<span>
|
||||
<i class="fab fa-github"></i>
|
||||
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="phpdocumentor">
|
||||
<div class="phpdocumentor-section">
|
||||
<input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
|
||||
<label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
|
||||
Menu
|
||||
</label>
|
||||
<aside class="phpdocumentor-column -three phpdocumentor-sidebar">
|
||||
<section class="phpdocumentor-sidebar__category -documentation">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Documentation</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/usage/requirements.html#requirements" class="">Requirements</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/usage/installation.html#installation" class="">Installation</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/changelog.html#changelog" class="">Changelog</a>
|
||||
</h4>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -namespaces">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="namespaces/occ.html" class="">OCC</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="namespaces/occ-basics.html" class="">Basics</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<section class="phpdocumentor-sidebar__category -packages">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="packages/Basics.html" class="">Basics</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="packages/Basics-DataStructures.html" class="">DataStructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-ErrorHandlers.html" class="">ErrorHandlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Interfaces.html" class="">Interfaces</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="packages/Basics-Traits.html" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -reports">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
|
||||
</section>
|
||||
|
||||
<section class="phpdocumentor-sidebar__category -indices">
|
||||
<h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
|
||||
<h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="phpdocumentor-column -nine phpdocumentor-content">
|
||||
<section>
|
||||
<ul class="phpdocumentor-breadcrumbs">
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ.html">OCC</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ-basics.html">Basics</a></li>
|
||||
<li class="phpdocumentor-breadcrumb"><a href="namespaces/occ-basics-datastructures.html">DataStructures</a></li>
|
||||
</ul>
|
||||
|
||||
<article class="phpdocumentor-element -namespace">
|
||||
<h2 class="phpdocumentor-content__title">Traits</h2>
|
||||
|
||||
|
||||
<h3 id="toc">
|
||||
Table of Contents
|
||||
<a href="namespaces/occ-basics-datastructures-traits.html#toc" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 id="toc-traits">
|
||||
Traits
|
||||
<a href="namespaces/occ-basics-datastructures-traits.html#toc-traits" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html"><abbr title="\OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait">StrictSplDatastructureTrait</abbr></a></dt><dd>The common interface of all type-sensitive, SPL-based datastructures.</dd> </dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="phpdocumentor-modal" id="source-view">
|
||||
<div class="phpdocumentor-modal-bg" data-exit-button></div>
|
||||
<div class="phpdocumentor-modal-container">
|
||||
<div class="phpdocumentor-modal-content">
|
||||
<pre style="max-height: 500px; overflow-y: scroll" data-src="" class="language-php line-numbers linkable-line-numbers"></pre>
|
||||
</div>
|
||||
<button data-exit-button class="phpdocumentor-modal__close">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
function loadExternalCodeSnippet(el, url, line) {
|
||||
Array.prototype.slice.call(el.querySelectorAll('pre[data-src]')).forEach((pre) => {
|
||||
const src = url || pre.getAttribute('data-src').replace(/\\/g, '/');
|
||||
const language = 'php';
|
||||
|
||||
const code = document.createElement('code');
|
||||
code.className = 'language-' + language;
|
||||
pre.textContent = '';
|
||||
pre.setAttribute('data-line', line)
|
||||
code.textContent = 'Loading…';
|
||||
pre.appendChild(code);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', src, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status < 400 && xhr.responseText) {
|
||||
code.textContent = xhr.responseText;
|
||||
Prism.highlightElement(code);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status === 404) {
|
||||
code.textContent = '✖ Error: File could not be found';
|
||||
return;
|
||||
}
|
||||
|
||||
if (xhr.status >= 400) {
|
||||
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
|
||||
return;
|
||||
}
|
||||
|
||||
code.textContent = '✖ Error: An unknown error occurred';
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
const modalButtons = document.querySelectorAll("[data-modal]");
|
||||
const openedAsLocalFile = window.location.protocol === 'file:';
|
||||
if (modalButtons.length > 0 && openedAsLocalFile) {
|
||||
console.warn(
|
||||
'Viewing the source code is unavailable because you are opening this page from the file:// scheme; ' +
|
||||
'browsers block XHR requests when a page is opened this way'
|
||||
);
|
||||
}
|
||||
|
||||
modalButtons.forEach(function (trigger) {
|
||||
if (openedAsLocalFile) {
|
||||
trigger.setAttribute("hidden", "hidden");
|
||||
}
|
||||
|
||||
trigger.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
const modal = document.getElementById(trigger.dataset.modal);
|
||||
if (!modal) {
|
||||
console.error(`Modal with id "${trigger.dataset.modal}" could not be found`);
|
||||
return;
|
||||
}
|
||||
modal.classList.add("phpdocumentor-modal__open");
|
||||
|
||||
loadExternalCodeSnippet(modal, trigger.dataset.src || null, trigger.dataset.line)
|
||||
const exits = modal.querySelectorAll("[data-exit-button]");
|
||||
exits.forEach(function (exit) {
|
||||
exit.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
modal.classList.remove("phpdocumentor-modal__open");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
</article>
|
||||
</section>
|
||||
<section class="phpdocumentor-on-this-page__sidebar">
|
||||
|
||||
<section class="phpdocumentor-on-this-page__content">
|
||||
<strong class="phpdocumentor-on-this-page__title">On this page</strong>
|
||||
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li class="phpdocumentor-on-this-page-section__title">Table Of Contents</li>
|
||||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="namespaces/occ-basics-datastructures-traits.html#toc-traits">Traits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
|
||||
<section class="phpdocumentor-search-results__dialog">
|
||||
<header class="phpdocumentor-search-results__header">
|
||||
<h2 class="phpdocumentor-search-results__title">Search results</h2>
|
||||
<button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
|
||||
</header>
|
||||
<section class="phpdocumentor-search-results__body">
|
||||
<ul class="phpdocumentor-search-results__entries"></ul>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<a href="namespaces/occ-basics-datastructures-traits.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
cssVars({});
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -166,6 +184,15 @@
|
|||
</h3>
|
||||
|
||||
|
||||
<h4 id="namespaces">
|
||||
Namespaces
|
||||
<a href="namespaces/occ-basics-datastructures.html#namespaces" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -namespace"><a href="namespaces/occ-basics-datastructures-exceptions.html"><abbr title="\OCC\Basics\DataStructures\Exceptions">Exceptions</abbr></a></dt>
|
||||
<dt class="phpdocumentor-table-of-contents__entry -namespace"><a href="namespaces/occ-basics-datastructures-traits.html"><abbr title="\OCC\Basics\DataStructures\Traits">Traits</abbr></a></dt>
|
||||
</dl>
|
||||
|
||||
|
||||
<h4 id="toc-classes">
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -175,7 +193,7 @@
|
|||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Getter.html"><abbr title="\OCC\Basics\Traits\Getter">Getter</abbr></a></dt><dd>Reads data from inaccessible properties by using magic methods.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-OverloadingGetter.html"><abbr title="\OCC\Basics\Traits\OverloadingGetter">OverloadingGetter</abbr></a></dt><dd>Overloads a class with readable magic properties.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-OverloadingSetter.html"><abbr title="\OCC\Basics\Traits\OverloadingSetter">OverloadingSetter</abbr></a></dt><dd>Overloads a class with writable magic properties.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Setter.html"><abbr title="\OCC\Basics\Traits\Setter">Setter</abbr></a></dt><dd>Writes data to inaccessible properties by using magic methods.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Singleton.html"><abbr title="\OCC\Basics\Traits\Singleton">Singleton</abbr></a></dt><dd>Allows just a single instance of the class using this trait.</dd> </dl>
|
||||
<dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Getter.html"><abbr title="\OCC\Basics\Traits\Getter">Getter</abbr></a></dt><dd>Reads data from inaccessible properties by using magic methods.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-OverloadingGetter.html"><abbr title="\OCC\Basics\Traits\OverloadingGetter">OverloadingGetter</abbr></a></dt><dd>Overloads a class with readable magic properties.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-OverloadingSetter.html"><abbr title="\OCC\Basics\Traits\OverloadingSetter">OverloadingSetter</abbr></a></dt><dd>Overloads a class with writable magic properties.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Setter.html"><abbr title="\OCC\Basics\Traits\Setter">Setter</abbr></a></dt><dd>Writes data to inaccessible properties by using magic methods.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Singleton.html"><abbr title="\OCC\Basics\Traits\Singleton">Singleton</abbr></a></dt><dd>Allows just a single instance of the class using this trait.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-TypeChecker.html"><abbr title="\OCC\Basics\Traits\TypeChecker">TypeChecker</abbr></a></dt><dd>A generic data type checker.</dd> </dl>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -173,8 +191,15 @@
|
|||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -class"><a href="classes/OCC-Basics-DataStructures-StrictCollection.html"><abbr title="\OCC\Basics\DataStructures\StrictCollection">StrictCollection</abbr></a></dt><dd>A type-sensitive, unsorted collection.</dd> <dt class="phpdocumentor-table-of-contents__entry -class"><a href="classes/OCC-Basics-DataStructures-StrictList.html"><abbr title="\OCC\Basics\DataStructures\StrictList">StrictList</abbr></a></dt><dd>A type-sensitive, taversable list.</dd> <dt class="phpdocumentor-table-of-contents__entry -class"><a href="classes/OCC-Basics-DataStructures-StrictQueue.html"><abbr title="\OCC\Basics\DataStructures\StrictQueue">StrictQueue</abbr></a></dt><dd>A type-sensitive, taversable queue (FIFO).</dd> <dt class="phpdocumentor-table-of-contents__entry -class"><a href="classes/OCC-Basics-DataStructures-StrictStack.html"><abbr title="\OCC\Basics\DataStructures\StrictStack">StrictStack</abbr></a></dt><dd>A type-sensitive, taversable stack (LIFO).</dd> </dl>
|
||||
<dt class="phpdocumentor-table-of-contents__entry -class"><a href="classes/OCC-Basics-DataStructures-Exceptions-InvalidDataTypeException.html"><abbr title="\OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException">InvalidDataTypeException</abbr></a></dt><dd>Common exception for type-sensitive datastructures.</dd> <dt class="phpdocumentor-table-of-contents__entry -class"><a href="classes/OCC-Basics-DataStructures-StrictCollection.html"><abbr title="\OCC\Basics\DataStructures\StrictCollection">StrictCollection</abbr></a></dt><dd>A type-sensitive, unsorted collection.</dd> <dt class="phpdocumentor-table-of-contents__entry -class"><a href="classes/OCC-Basics-DataStructures-StrictList.html"><abbr title="\OCC\Basics\DataStructures\StrictList">StrictList</abbr></a></dt><dd>A type-sensitive, taversable list.</dd> <dt class="phpdocumentor-table-of-contents__entry -class"><a href="classes/OCC-Basics-DataStructures-StrictQueue.html"><abbr title="\OCC\Basics\DataStructures\StrictQueue">StrictQueue</abbr></a></dt><dd>A type-sensitive, taversable queue (FIFO).</dd> <dt class="phpdocumentor-table-of-contents__entry -class"><a href="classes/OCC-Basics-DataStructures-StrictStack.html"><abbr title="\OCC\Basics\DataStructures\StrictStack">StrictStack</abbr></a></dt><dd>A type-sensitive, taversable stack (LIFO).</dd> </dl>
|
||||
|
||||
<h4 id="toc-traits">
|
||||
Traits
|
||||
<a href="packages/Basics-DataStructures.html#toc-traits" class="headerlink"><i class="fas fa-link"></i></a>
|
||||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-DataStructures-Traits-StrictSplDatastructureTrait.html"><abbr title="\OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait">StrictSplDatastructureTrait</abbr></a></dt><dd>The common interface of all type-sensitive, SPL-based datastructures.</dd> </dl>
|
||||
|
||||
|
||||
|
||||
|
@ -289,7 +314,8 @@
|
|||
<li>
|
||||
<ul class="phpdocumentor-list -clean">
|
||||
<li><a href="packages/Basics-DataStructures.html#toc-classes">Classes</a></li>
|
||||
</ul>
|
||||
<li><a href="packages/Basics-DataStructures.html#toc-traits">Traits</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
@ -174,7 +192,7 @@
|
|||
|
||||
</h4>
|
||||
<dl class="phpdocumentor-table-of-contents">
|
||||
<dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Getter.html"><abbr title="\OCC\Basics\Traits\Getter">Getter</abbr></a></dt><dd>Reads data from inaccessible properties by using magic methods.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-OverloadingGetter.html"><abbr title="\OCC\Basics\Traits\OverloadingGetter">OverloadingGetter</abbr></a></dt><dd>Overloads a class with readable magic properties.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-OverloadingSetter.html"><abbr title="\OCC\Basics\Traits\OverloadingSetter">OverloadingSetter</abbr></a></dt><dd>Overloads a class with writable magic properties.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Setter.html"><abbr title="\OCC\Basics\Traits\Setter">Setter</abbr></a></dt><dd>Writes data to inaccessible properties by using magic methods.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Singleton.html"><abbr title="\OCC\Basics\Traits\Singleton">Singleton</abbr></a></dt><dd>Allows just a single instance of the class using this trait.</dd> </dl>
|
||||
<dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Getter.html"><abbr title="\OCC\Basics\Traits\Getter">Getter</abbr></a></dt><dd>Reads data from inaccessible properties by using magic methods.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-OverloadingGetter.html"><abbr title="\OCC\Basics\Traits\OverloadingGetter">OverloadingGetter</abbr></a></dt><dd>Overloads a class with readable magic properties.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-OverloadingSetter.html"><abbr title="\OCC\Basics\Traits\OverloadingSetter">OverloadingSetter</abbr></a></dt><dd>Overloads a class with writable magic properties.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Setter.html"><abbr title="\OCC\Basics\Traits\Setter">Setter</abbr></a></dt><dd>Writes data to inaccessible properties by using magic methods.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-Singleton.html"><abbr title="\OCC\Basics\Traits\Singleton">Singleton</abbr></a></dt><dd>Allows just a single instance of the class using this trait.</dd> <dt class="phpdocumentor-table-of-contents__entry -trait"><a href="classes/OCC-Basics-Traits-TypeChecker.html"><abbr title="\OCC\Basics\Traits\TypeChecker">TypeChecker</abbr></a></dt><dd>A generic data type checker.</dd> </dl>
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -76,6 +76,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -77,6 +77,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -77,6 +77,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -77,6 +77,24 @@
|
|||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/overview/index.html#overview" class="">Overview</a>
|
||||
</h4>
|
||||
<ul class="phpdocumentor-list">
|
||||
<li>
|
||||
<a href="guides/overview/datastructures.html#typed-datastructures" class="">Typed Datastructures</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/errorhandlers.html#error-and-exception-handlers" class="">Error and Exception Handlers</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/interfaces.html#interface-traits" class="">Interface Traits</a>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a href="guides/overview/traits.html#traits" class="">Traits</a>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4 class="phpdocumentor-sidebar__root-namespace">
|
||||
<a href="guides/usage/index.html#user-guide" class="">User Guide</a>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCC\Basics\DataStructures\Exceptions;
|
||||
|
||||
use DomainException;
|
||||
|
||||
/**
|
||||
* Common exception for type-sensitive datastructures.
|
||||
*
|
||||
* Exception thrown if a value does not adhere to the defined list of valid
|
||||
* data types.
|
||||
*
|
||||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\DataStructures
|
||||
*/
|
||||
class InvalidDataTypeException extends DomainException
|
||||
{
|
||||
}
|
|
@ -27,35 +27,17 @@ use ArrayAccess;
|
|||
use Countable;
|
||||
use DomainException;
|
||||
use InvalidArgumentException;
|
||||
use OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException;
|
||||
use OCC\Basics\Interfaces\ArrayAccessTrait;
|
||||
use OCC\Basics\Interfaces\CountableTrait;
|
||||
use OCC\Basics\Traits\Getter;
|
||||
use OCC\Basics\Traits\TypeChecker;
|
||||
use OutOfRangeException;
|
||||
use Serializable;
|
||||
|
||||
use function array_is_list;
|
||||
use function array_map;
|
||||
use function array_sum;
|
||||
use function count;
|
||||
use function function_exists;
|
||||
use function get_debug_type;
|
||||
use function is_a;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_callable;
|
||||
use function is_countable;
|
||||
use function is_double;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
use function is_integer;
|
||||
use function is_iterable;
|
||||
use function is_long;
|
||||
use function is_null;
|
||||
use function is_numeric;
|
||||
use function is_resource;
|
||||
use function is_scalar;
|
||||
use function is_string;
|
||||
use function is_object;
|
||||
use function ltrim;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function unserialize;
|
||||
|
@ -73,8 +55,6 @@ use function unserialize;
|
|||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\DataStructures
|
||||
*
|
||||
* @property-read string[] $allowedTypes The allowed data types for items.
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @template AllowedType of mixed
|
||||
|
@ -86,35 +66,28 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
use ArrayAccessTrait;
|
||||
/** @use CountableTrait<AllowedType> */
|
||||
use CountableTrait;
|
||||
use Getter;
|
||||
|
||||
/**
|
||||
* The allowed data types for collection items.
|
||||
*
|
||||
* @var string[]
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected array $allowedTypes = [];
|
||||
use TypeChecker {
|
||||
setAllowedTypes as protected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds the collection's items.
|
||||
*
|
||||
* @var AllowedType[]
|
||||
* @var array<array-key, AllowedType>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected array $_data = [];
|
||||
|
||||
/**
|
||||
* Add/insert a new item at the specified index.
|
||||
* Add/insert a item at the specified index.
|
||||
*
|
||||
* @param array-key $offset The new item's index
|
||||
* @param AllowedType $value The new item
|
||||
* @param array-key $offset The item's index
|
||||
* @param AllowedType $value The item
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if `$offset` is not of allowed type
|
||||
* @throws InvalidDataTypeException if `$value` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -140,53 +113,25 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
*
|
||||
* @param array-key $offset The item's index
|
||||
*
|
||||
* @return ?AllowedType The item or NULL if key is invalid
|
||||
* @return AllowedType The item
|
||||
*
|
||||
* @throws OutOfRangeException when `$offset` is out of bounds
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function get(int|string $offset): mixed
|
||||
{
|
||||
return $this->offsetGet($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allowed data types for collection items.
|
||||
*
|
||||
* @return string[] The list of allowed data types
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getAllowedTypes(): array
|
||||
{
|
||||
return $this->allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the item's data type is allowed in the collection.
|
||||
*
|
||||
* @param AllowedType $value The item to check
|
||||
*
|
||||
* @return bool Whether the item's data type is allowed
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isAllowedType(mixed $value): bool
|
||||
{
|
||||
if (count($this->allowedTypes) === 0) {
|
||||
return true;
|
||||
if (!$this->offsetExists($offset)) {
|
||||
throw new OutOfRangeException(
|
||||
sprintf(
|
||||
'Offset %s is not a valid index key for this collection.',
|
||||
$offset
|
||||
)
|
||||
);
|
||||
}
|
||||
foreach ($this->allowedTypes as $type) {
|
||||
$function = 'is_' . $type;
|
||||
if (function_exists($function) && $function($value)) {
|
||||
return true;
|
||||
}
|
||||
/** @var class-string $fqcn */
|
||||
$fqcn = ltrim($type, '\\');
|
||||
if (is_object($value) && is_a($value, $fqcn)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
/** @var AllowedType $value */
|
||||
$value = $this->offsetGet($offset);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,7 +171,8 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if `$offset` or `$value` is not of allowed type
|
||||
* @throws InvalidDataTypeException if `$value` is not of allowed type
|
||||
* @throws InvalidArgumentException if `$offset` is not a valid array key
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -240,8 +186,8 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
)
|
||||
);
|
||||
}
|
||||
if (!$this->isAllowedType($value)) {
|
||||
throw new InvalidArgumentException(
|
||||
if (!$this->hasAllowedType($value)) {
|
||||
throw new InvalidDataTypeException(
|
||||
sprintf(
|
||||
'Parameter 2 must be an allowed type, %s given.',
|
||||
get_debug_type($value)
|
||||
|
@ -258,10 +204,20 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws OutOfRangeException when `$offset` is out of bounds
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function remove(int|string $offset): void
|
||||
{
|
||||
if (!$this->offsetExists($offset)) {
|
||||
throw new OutOfRangeException(
|
||||
sprintf(
|
||||
'Offset %s is not a valid index key for this collection.',
|
||||
$offset
|
||||
)
|
||||
);
|
||||
}
|
||||
$this->offsetUnset($offset);
|
||||
}
|
||||
|
||||
|
@ -283,7 +239,7 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if `$value` is not of allowed type
|
||||
* @throws InvalidDataTypeException if `$value` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -292,29 +248,10 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
$this->offsetSet($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set allowed data types of collection items.
|
||||
*
|
||||
* @param string[] $allowedTypes Allowed data types of items
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if any value of `$allowedTypes` is not a string
|
||||
*/
|
||||
protected function setAllowedTypes(array $allowedTypes = []): void
|
||||
{
|
||||
if (array_sum(array_map('is_string', $allowedTypes)) !== count($allowedTypes)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Allowed types must be array of strings or empty array.'
|
||||
);
|
||||
}
|
||||
$this->allowedTypes = $allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array representation of collection.
|
||||
*
|
||||
* @return AllowedType[] Array of collection items
|
||||
* @return array<array-key, AllowedType> Array of collection items
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
|
@ -338,12 +275,11 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
{
|
||||
if (!$this->isList()) {
|
||||
throw new DomainException(
|
||||
'Cannot convert into list: collection contains non-integer and/or non-consecutive keys.'
|
||||
'Cannot convert into StrictList: collection contains non-integer and/or non-consecutive keys.'
|
||||
);
|
||||
}
|
||||
$strictList = new StrictList($this->allowedTypes);
|
||||
$items = $this->toArray();
|
||||
$strictList->append(...$items);
|
||||
$strictList = new StrictList($this->getAllowedTypes());
|
||||
$strictList->append(...$this->toArray());
|
||||
return $strictList;
|
||||
}
|
||||
|
||||
|
@ -361,18 +297,6 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
$this->__unserialize($dataArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter method for $this->allowedTypes.
|
||||
*
|
||||
* @return string[] The list of allowed data types
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function _magicGetAllowedTypes(): array
|
||||
{
|
||||
return $this->getAllowedTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a type-sensitive collection of items.
|
||||
*
|
||||
|
@ -425,8 +349,8 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
public function __serialize(): array
|
||||
{
|
||||
return [
|
||||
'StrictCollection::allowedTypes' => $this->allowedTypes,
|
||||
'StrictCollection::items' => $this->_data
|
||||
'StrictCollection::allowedTypes' => $this->getAllowedTypes(),
|
||||
'StrictCollection::items' => $this->toArray()
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -446,7 +370,7 @@ class StrictCollection implements ArrayAccess, Countable, Serializable
|
|||
/** @var string[] $allowedTypes */
|
||||
$allowedTypes = $data['StrictCollection::allowedTypes'];
|
||||
$this->setAllowedTypes($allowedTypes);
|
||||
/** @var AllowedType[] $items */
|
||||
/** @var array<array-key, AllowedType> $items */
|
||||
$items = $data['StrictCollection::items'];
|
||||
foreach ($items as $offset => $value) {
|
||||
$this->offsetSet($offset, $value);
|
||||
|
|
|
@ -23,46 +23,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCC\Basics\DataStructures;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use InvalidArgumentException;
|
||||
use Iterator;
|
||||
use OutOfRangeException;
|
||||
use RangeException;
|
||||
use RuntimeException;
|
||||
use OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait;
|
||||
use SplDoublyLinkedList;
|
||||
use OCC\Basics\Traits\Getter;
|
||||
use Serializable;
|
||||
|
||||
use function array_map;
|
||||
use function array_sum;
|
||||
use function count;
|
||||
use function function_exists;
|
||||
use function get_debug_type;
|
||||
use function in_array;
|
||||
use function is_a;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_callable;
|
||||
use function is_countable;
|
||||
use function is_double;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
use function is_integer;
|
||||
use function is_iterable;
|
||||
use function is_long;
|
||||
use function is_null;
|
||||
use function is_numeric;
|
||||
use function is_resource;
|
||||
use function is_scalar;
|
||||
use function is_string;
|
||||
use function is_object;
|
||||
use function iterator_to_array;
|
||||
use function ltrim;
|
||||
use function range;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* A type-sensitive, taversable list.
|
||||
|
@ -74,709 +36,13 @@ use function unserialize;
|
|||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\DataStructures
|
||||
*
|
||||
* @property-read string[] $allowedTypes The allowed data types for values.
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @template AllowedType of mixed
|
||||
* @extends SplDoublyLinkedList<AllowedType>
|
||||
* @implements ArrayAccess<int, AllowedType>
|
||||
* @implements Iterator<AllowedType>
|
||||
*/
|
||||
class StrictList extends SplDoublyLinkedList implements ArrayAccess, Countable, Iterator, Serializable
|
||||
class StrictList extends SplDoublyLinkedList
|
||||
{
|
||||
use Getter;
|
||||
|
||||
/**
|
||||
* The allowed data types for list items.
|
||||
*
|
||||
* @var string[]
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected array $allowedTypes = [];
|
||||
|
||||
/**
|
||||
* 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<int, AllowedType> $values */
|
||||
foreach ($values as $count => $value) {
|
||||
if (!$this->isAllowedType($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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Peek at the item at the beginning of the list.
|
||||
*
|
||||
* @return AllowedType The first item of the list
|
||||
*
|
||||
* @throws RuntimeException if the list is empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function bottom(): mixed
|
||||
{
|
||||
return parent::bottom();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the list of any items.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function clear(): void
|
||||
{
|
||||
while (!$this->isEmpty()) {
|
||||
$this->pop();
|
||||
}
|
||||
$this->rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of items on the list.
|
||||
*
|
||||
* @return int The number of items on the list
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return parent::count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current list item.
|
||||
*
|
||||
* @return AllowedType The current item
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function current(): mixed
|
||||
{
|
||||
return parent::current();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get allowed data types for list items.
|
||||
*
|
||||
* @return string[] The list of allowed data types
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getAllowedTypes(): array
|
||||
{
|
||||
return $this->allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mode of iteration.
|
||||
*
|
||||
* @return int The set of flags and modes of iteration
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getIteratorMode(): int
|
||||
{
|
||||
return parent::getIteratorMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the item's data type is allowed on the list.
|
||||
*
|
||||
* @param AllowedType $value The item to check
|
||||
*
|
||||
* @return bool Whether the item's data type is allowed
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isAllowedType(mixed $value): bool
|
||||
{
|
||||
if (count($this->allowedTypes) === 0) {
|
||||
return true;
|
||||
}
|
||||
foreach ($this->allowedTypes as $type) {
|
||||
$function = 'is_' . $type;
|
||||
if (function_exists($function) && $function($value)) {
|
||||
return true;
|
||||
}
|
||||
/** @var class-string $fqcn */
|
||||
$fqcn = ltrim($type, '\\');
|
||||
if (is_object($value) && is_a($value, $fqcn)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if list is empty.
|
||||
*
|
||||
* @return bool Whether the list contains no items
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return parent::isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current list index.
|
||||
*
|
||||
* @return int The current list index
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function key(): int
|
||||
{
|
||||
return parent::key();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the cursor to the next list index.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function next(): void
|
||||
{
|
||||
parent::next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the specified index exists and is not empty.
|
||||
*
|
||||
* @param int $offset The index to check
|
||||
*
|
||||
* @return bool Whether the index exists and is not empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function offsetExists(mixed $offset): bool
|
||||
{
|
||||
return parent::offsetExists($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item from 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 offsetGet(mixed $offset): mixed
|
||||
{
|
||||
return parent::offsetGet($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->isAllowedType($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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the item at the specified index.
|
||||
*
|
||||
* @param int $offset The item's index
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws OutOfRangeException when `$offset` is out of bounds
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function offsetUnset(mixed $offset): void
|
||||
{
|
||||
parent::offsetUnset($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pops an item from the end of the list.
|
||||
*
|
||||
* @return AllowedType The item from the end of the list
|
||||
*
|
||||
* @throws RuntimeException if the list is empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function pop(): mixed
|
||||
{
|
||||
return parent::pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<int, AllowedType> $values */
|
||||
foreach ($values as $count => $value) {
|
||||
if (!$this->isAllowedType($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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the cursor to the previous list index.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function prev(): void
|
||||
{
|
||||
parent::prev();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->isAllowedType($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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind the iterator's cursor.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function rewind(): void
|
||||
{
|
||||
parent::rewind();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set allowed data types of list items.
|
||||
*
|
||||
* @param string[] $allowedTypes Allowed data types of items
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if any value of `$allowedTypes` is not a string
|
||||
*/
|
||||
protected function setAllowedTypes(array $allowedTypes = []): void
|
||||
{
|
||||
if (array_sum(array_map('is_string', $allowedTypes)) !== count($allowedTypes)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Allowed types must be array of strings or empty array.'
|
||||
);
|
||||
}
|
||||
$this->allowedTypes = $allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mode of iteration.
|
||||
*
|
||||
* @param int $mode The new iterator mode (0, 1, 2 or 3)
|
||||
*
|
||||
* There are two orthogonal sets of modes that can be set.
|
||||
*
|
||||
* The direction of iteration (either one or the other):
|
||||
* - StrictList::IT_MODE_FIFO (queue style)
|
||||
* - StrictList::IT_MODE_LIFO (stack style)
|
||||
*
|
||||
* The behavior of the iterator (either one or the other):
|
||||
* - StrictList::IT_MODE_DELETE (delete items)
|
||||
* - StrictList::IT_MODE_KEEP (keep items)
|
||||
*
|
||||
* The default mode is: IT_MODE_FIFO | IT_MODE_KEEP
|
||||
*
|
||||
* @return int The set of flags and modes of iteration
|
||||
*
|
||||
* @throws RangeException if an invalid `$mode` is given
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setIteratorMode(int $mode): int
|
||||
{
|
||||
if (!in_array($mode, range(0, 3), true)) {
|
||||
throw new RangeException(
|
||||
sprintf(
|
||||
'Iterator mode must be an integer in range [0..3], %d given.',
|
||||
$mode
|
||||
)
|
||||
);
|
||||
}
|
||||
return parent::setIteratorMode($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift an item from the beginning of the list.
|
||||
*
|
||||
* @return AllowedType The first item of the list
|
||||
*
|
||||
* @throws RuntimeException if the list is empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function shift(): mixed
|
||||
{
|
||||
return parent::shift();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array representation of list.
|
||||
*
|
||||
* @return AllowedType[] Array of list items
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return iterator_to_array($this, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn list into a type-sensitive collection.
|
||||
*
|
||||
* @return StrictCollection<AllowedType> A type-sensitive collection of the list's items
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function toStrictCollection(): StrictCollection
|
||||
{
|
||||
$strictCollection = new StrictCollection($this->allowedTypes);
|
||||
foreach ($this->toArray() as $offset => $value) {
|
||||
$strictCollection[$offset] = $value;
|
||||
}
|
||||
return $strictCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Peek at the item at the end of the list.
|
||||
*
|
||||
* @return AllowedType The last item of the list
|
||||
*
|
||||
* @throws RuntimeException if the list is empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function top(): mixed
|
||||
{
|
||||
return parent::top();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->isAllowedType($value)) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'Parameter 1 must be an allowed type, %s given.',
|
||||
get_debug_type($value)
|
||||
)
|
||||
);
|
||||
}
|
||||
parent::unshift($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current cursor position is valid.
|
||||
*
|
||||
* @return bool Whether the current cursor position is valid
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function valid(): bool
|
||||
{
|
||||
return parent::valid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter method for $this->allowedTypes.
|
||||
*
|
||||
* @return string[] The list of allowed data types
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function _magicGetAllowedTypes(): array
|
||||
{
|
||||
return $this->getAllowedTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 [
|
||||
'StrictList::allowedTypes' => $this->allowedTypes,
|
||||
'SplDoublyLinkedList::dllist' => iterator_to_array($this),
|
||||
'SplDoublyLinkedList::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['StrictList::allowedTypes'];
|
||||
$this->setAllowedTypes($allowedTypes);
|
||||
/** @var array<int, AllowedType> $values */
|
||||
$values = $data['SplDoublyLinkedList::dllist'];
|
||||
$this->append(...$values);
|
||||
/** @var int $flags */
|
||||
$flags = $data['SplDoublyLinkedList::flags'];
|
||||
$this->setIteratorMode($flags);
|
||||
}
|
||||
/** @use StrictSplDatastructureTrait<AllowedType> */
|
||||
use StrictSplDatastructureTrait;
|
||||
}
|
||||
|
|
|
@ -23,24 +23,16 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCC\Basics\DataStructures;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use InvalidArgumentException;
|
||||
use Iterator;
|
||||
use RangeException;
|
||||
use RuntimeException;
|
||||
use Serializable;
|
||||
|
||||
use function sprintf;
|
||||
use OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException;
|
||||
use OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait;
|
||||
use SplQueue;
|
||||
|
||||
/**
|
||||
* A type-sensitive, taversable queue (FIFO).
|
||||
*
|
||||
* Extends [\SplDoublyLinkedList](https://www.php.net/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. It
|
||||
* also restricts the iterator direction to first-in, first-out (FIFO) exactly
|
||||
* like [\SplQueue](https://www.php.net/splqueue).
|
||||
* Extends [\SplQueue](https://www.php.net/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.
|
||||
*
|
||||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\DataStructures
|
||||
|
@ -48,23 +40,12 @@ use function sprintf;
|
|||
* @api
|
||||
*
|
||||
* @template AllowedType of mixed
|
||||
* @extends StrictList<AllowedType>
|
||||
* @implements ArrayAccess<int, AllowedType>
|
||||
* @implements Iterator<AllowedType>
|
||||
* @extends SplQueue<AllowedType>
|
||||
*/
|
||||
class StrictQueue extends StrictList implements ArrayAccess, Countable, Iterator, Serializable
|
||||
class StrictQueue extends SplQueue
|
||||
{
|
||||
/**
|
||||
* Dequeue an item from the queue.
|
||||
*
|
||||
* @return AllowedType The dequeued item
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function dequeue(): mixed
|
||||
{
|
||||
return parent::shift();
|
||||
}
|
||||
/** @use StrictSplDatastructureTrait<AllowedType> */
|
||||
use StrictSplDatastructureTrait;
|
||||
|
||||
/**
|
||||
* Add an item to the queue.
|
||||
|
@ -73,79 +54,12 @@ class StrictQueue extends StrictList implements ArrayAccess, Countable, Iterator
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if `$value` is not of allowed type
|
||||
* @throws InvalidDataTypeException if `$value` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function enqueue(mixed $value): void
|
||||
{
|
||||
parent::push($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mode of iteration.
|
||||
*
|
||||
* @param int $mode The new iterator mode (0 or 1)
|
||||
*
|
||||
* There are two orthogonal sets of modes that can be set.
|
||||
*
|
||||
* The direction of iteration (fixed for StrictQueue):
|
||||
* - StrictQueue::IT_MODE_FIFO (queue style)
|
||||
*
|
||||
* The behavior of the iterator (either one or the other):
|
||||
* - StrictQueue::IT_MODE_DELETE (delete items)
|
||||
* - StrictQueue::IT_MODE_KEEP (keep items)
|
||||
*
|
||||
* The default mode is: IT_MODE_FIFO | IT_MODE_KEEP
|
||||
*
|
||||
* @return int The set of flags and modes of iteration
|
||||
*
|
||||
* @throws RangeException if an invalid `$mode` is given
|
||||
* @throws RuntimeException if trying to change iterator direction
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
final public function setIteratorMode(int $mode): int
|
||||
{
|
||||
if ($mode > 1) {
|
||||
throw new RuntimeException(
|
||||
sprintf(
|
||||
'Changing the iterator direction of %s is prohibited.',
|
||||
static::class
|
||||
)
|
||||
);
|
||||
}
|
||||
return parent::setIteratorMode($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a type-sensitive, traversable queue 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 = [])
|
||||
{
|
||||
parent::__construct($allowedTypes);
|
||||
$this->setIteratorMode(0);
|
||||
$this->push($value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,24 +23,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCC\Basics\DataStructures;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use InvalidArgumentException;
|
||||
use Iterator;
|
||||
use RangeException;
|
||||
use OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException;
|
||||
use OCC\Basics\DataStructures\Traits\StrictSplDatastructureTrait;
|
||||
use RuntimeException;
|
||||
use Serializable;
|
||||
|
||||
use function sprintf;
|
||||
use SplStack;
|
||||
|
||||
/**
|
||||
* A type-sensitive, taversable stack (LIFO).
|
||||
*
|
||||
* Extends [\SplDoublyLinkedList](https://www.php.net/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. It
|
||||
* also restricts the iterator direction to last-in, first-out (LIFO) exactly
|
||||
* like [\SplStack](https://www.php.net/splstack).
|
||||
* Extends [\SplStack](https://www.php.net/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.
|
||||
*
|
||||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\DataStructures
|
||||
|
@ -48,12 +41,13 @@ use function sprintf;
|
|||
* @api
|
||||
*
|
||||
* @template AllowedType of mixed
|
||||
* @extends StrictList<AllowedType>
|
||||
* @implements ArrayAccess<int, AllowedType>
|
||||
* @implements Iterator<AllowedType>
|
||||
* @extends SplStack<AllowedType>
|
||||
*/
|
||||
class StrictStack extends StrictList implements ArrayAccess, Countable, Iterator, Serializable
|
||||
class StrictStack extends SplStack
|
||||
{
|
||||
/** @use StrictSplDatastructureTrait<AllowedType> */
|
||||
use StrictSplDatastructureTrait;
|
||||
|
||||
/**
|
||||
* Add an item to the stack.
|
||||
*
|
||||
|
@ -61,13 +55,13 @@ class StrictStack extends StrictList implements ArrayAccess, Countable, Iterator
|
|||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if `$value` is not of allowed type
|
||||
* @throws InvalidDataTypeException if `$value` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function stack(mixed $value): void
|
||||
{
|
||||
parent::push($value);
|
||||
$this->push($value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,77 +69,12 @@ class StrictStack extends StrictList implements ArrayAccess, Countable, Iterator
|
|||
*
|
||||
* @return AllowedType The unstacked item
|
||||
*
|
||||
* @throws RuntimeException if the list is empty
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function unstack(): mixed
|
||||
{
|
||||
return parent::pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mode of iteration.
|
||||
*
|
||||
* @param int $mode The new iterator mode (2 or 3)
|
||||
*
|
||||
* There are two orthogonal sets of modes that can be set.
|
||||
*
|
||||
* The direction of iteration (fixed for StrictStack):
|
||||
* - StrictStack::IT_MODE_LIFO (stack style)
|
||||
*
|
||||
* The behavior of the iterator (either one or the other):
|
||||
* - StrictStack::IT_MODE_DELETE (delete items)
|
||||
* - StrictStack::IT_MODE_KEEP (keep items)
|
||||
*
|
||||
* The default mode is: IT_MODE_LIFO | IT_MODE_KEEP
|
||||
*
|
||||
* @return int The set of flags and modes of iteration
|
||||
*
|
||||
* @throws RangeException if an invalid `$mode` is given
|
||||
* @throws RuntimeException if trying to change iterator direction
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
final public function setIteratorMode(int $mode): int
|
||||
{
|
||||
if ($mode < 2) {
|
||||
throw new RuntimeException(
|
||||
sprintf(
|
||||
'Changing the iterator direction of %s is prohibited.',
|
||||
static::class
|
||||
)
|
||||
);
|
||||
}
|
||||
return parent::setIteratorMode($mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a type-sensitive, traversable stack 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 = [])
|
||||
{
|
||||
parent::__construct($allowedTypes);
|
||||
$this->setIteratorMode(2);
|
||||
return $this->pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,422 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCC\Basics\DataStructures\Traits;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OCC\Basics\DataStructures\Exceptions\InvalidDataTypeException;
|
||||
use OCC\Basics\DataStructures\StrictCollection;
|
||||
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 <sebastian.meyer@opencultureconsulting.com>
|
||||
* @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 InvalidDataTypeException 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 InvalidDataTypeException if any `$values` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function append(mixed ...$values): void
|
||||
{
|
||||
/** @var array<int, AllowedType> $values */
|
||||
foreach ($values as $count => $value) {
|
||||
if (!$this->hasAllowedType($value)) {
|
||||
throw new InvalidDataTypeException(
|
||||
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 InvalidDataTypeException 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 InvalidDataTypeException(
|
||||
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 InvalidDataTypeException if `$value` is not of allowed type
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function prepend(mixed ...$values): void
|
||||
{
|
||||
/** @var array<int, AllowedType> $values */
|
||||
foreach ($values as $count => $value) {
|
||||
if (!$this->hasAllowedType($value)) {
|
||||
throw new InvalidDataTypeException(
|
||||
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 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)
|
||||
)
|
||||
);
|
||||
}
|
||||
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 InvalidDataTypeException 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<int, AllowedType> Array of list items
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return iterator_to_array($this, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn list into a type-sensitive collection.
|
||||
*
|
||||
* @return StrictCollection<AllowedType> 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 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)
|
||||
)
|
||||
);
|
||||
}
|
||||
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<int, AllowedType> $values */
|
||||
$values = $data['StrictSplDatastructure::dllist'];
|
||||
$this->append(...$values);
|
||||
/** @var int $flags */
|
||||
$flags = $data['StrictSplDatastructure::flags'];
|
||||
$this->setIteratorMode($flags);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCC\Basics\Traits;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
use function array_map;
|
||||
use function array_sum;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function function_exists;
|
||||
use function in_array;
|
||||
use function is_a;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_callable;
|
||||
use function is_countable;
|
||||
use function is_double;
|
||||
use function is_float;
|
||||
use function is_int;
|
||||
use function is_integer;
|
||||
use function is_iterable;
|
||||
use function is_long;
|
||||
use function is_null;
|
||||
use function is_numeric;
|
||||
use function is_resource;
|
||||
use function is_scalar;
|
||||
use function is_string;
|
||||
use function is_object;
|
||||
use function ltrim;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
|
||||
* @package Basics\Traits
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
trait TypeChecker
|
||||
{
|
||||
/**
|
||||
* The allowed data types.
|
||||
*
|
||||
* @var string[]
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
protected array $_allowedTypes = [];
|
||||
|
||||
/**
|
||||
* Get allowed data types.
|
||||
*
|
||||
* @return string[] The list of allowed data types
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function getAllowedTypes(): array
|
||||
{
|
||||
return $this->_allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a value's data type is allowed.
|
||||
*
|
||||
* @param mixed $value The value to check
|
||||
*
|
||||
* @return bool Whether the value's data type is allowed
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function hasAllowedType(mixed $value): bool
|
||||
{
|
||||
if (count($this->getAllowedTypes()) === 0) {
|
||||
return true;
|
||||
}
|
||||
foreach ($this->getAllowedTypes() as $type) {
|
||||
$function = 'is_' . $type;
|
||||
if (function_exists($function) && $function($value)) {
|
||||
return true;
|
||||
}
|
||||
/** @var class-string $fqcn */
|
||||
$fqcn = ltrim($type, '\\');
|
||||
if (is_object($value) && is_a($value, $fqcn)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a data type is allowed.
|
||||
*
|
||||
* @param string $type The type to check
|
||||
*
|
||||
* @return bool Whether the data type is allowed
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function isAllowedType(string $type): bool
|
||||
{
|
||||
return in_array($type, $this->getAllowedTypes(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set allowed data types.
|
||||
*
|
||||
* @param string[] $allowedTypes Allowed data types
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidArgumentException if any value of `$allowedTypes` is not a string
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setAllowedTypes(array $allowedTypes = []): void
|
||||
{
|
||||
if (array_sum(array_map('is_string', $allowedTypes)) !== count($allowedTypes)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Allowed types must be array of strings or empty array.'
|
||||
);
|
||||
}
|
||||
$this->_allowedTypes = array_values($allowedTypes);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue