summaryrefslogtreecommitdiffstats
path: root/vendor/doctrine/collections/docs/en
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:31:45 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:31:45 +0000
commit4e393913a4b1f06509da4341f0f58a41adac9117 (patch)
tree9c27e3eb77d109dff5fd031502311c5616adab04 /vendor/doctrine/collections/docs/en
parentInitial commit. (diff)
downloadicinga-php-thirdparty-4e393913a4b1f06509da4341f0f58a41adac9117.tar.xz
icinga-php-thirdparty-4e393913a4b1f06509da4341f0f58a41adac9117.zip
Adding upstream version 0.12.1+ds.upstream/0.12.1+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/doctrine/collections/docs/en')
-rw-r--r--vendor/doctrine/collections/docs/en/derived-collections.rst26
-rw-r--r--vendor/doctrine/collections/docs/en/expression-builder.rst173
-rw-r--r--vendor/doctrine/collections/docs/en/expressions.rst102
-rw-r--r--vendor/doctrine/collections/docs/en/index.rst333
-rw-r--r--vendor/doctrine/collections/docs/en/lazy-collections.rst26
-rw-r--r--vendor/doctrine/collections/docs/en/sidebar.rst8
6 files changed, 668 insertions, 0 deletions
diff --git a/vendor/doctrine/collections/docs/en/derived-collections.rst b/vendor/doctrine/collections/docs/en/derived-collections.rst
new file mode 100644
index 0000000..03d9da5
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/derived-collections.rst
@@ -0,0 +1,26 @@
+Derived Collections
+===================
+
+You can create custom collection classes by extending the
+``Doctrine\Common\Collections\ArrayCollection`` class. If the
+``__construct`` semantics are different from the default ``ArrayCollection``
+you can override the ``createFrom`` method:
+
+.. code-block:: php
+ final class DerivedArrayCollection extends ArrayCollection
+ {
+ /** @var \stdClass */
+ private $foo;
+
+ public function __construct(\stdClass $foo, array $elements = [])
+ {
+ $this->foo = $foo;
+
+ parent::__construct($elements);
+ }
+
+ protected function createFrom(array $elements) : self
+ {
+ return new static($this->foo, $elements);
+ }
+ }
diff --git a/vendor/doctrine/collections/docs/en/expression-builder.rst b/vendor/doctrine/collections/docs/en/expression-builder.rst
new file mode 100644
index 0000000..ad4055b
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/expression-builder.rst
@@ -0,0 +1,173 @@
+Expression Builder
+==================
+
+The Expression Builder is a convenient fluent interface for
+building expressions to be used with the ``Doctrine\Common\Collections\Criteria``
+class:
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $criteria = new Criteria();
+ $criteria->where($expressionBuilder->eq('name', 'jwage'));
+ $criteria->orWhere($expressionBuilder->eq('name', 'romanb'));
+
+ $collection->matching($criteria);
+
+The ``ExpressionBuilder`` has the following API:
+
+andX
+----
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->andX(
+ $expressionBuilder->eq('foo', 1),
+ $expressionBuilder->eq('bar', 1)
+ );
+
+ $collection->matching(new Criteria($expression));
+
+orX
+---
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->orX(
+ $expressionBuilder->eq('foo', 1),
+ $expressionBuilder->eq('bar', 1)
+ );
+
+ $collection->matching(new Criteria($expression));
+
+eq
+---
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->eq('foo', 1);
+
+ $collection->matching(new Criteria($expression));
+
+gt
+---
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->gt('foo', 1);
+
+ $collection->matching(new Criteria($expression));
+
+lt
+---
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->lt('foo', 1);
+
+ $collection->matching(new Criteria($expression));
+
+gte
+---
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->gte('foo', 1);
+
+ $collection->matching(new Criteria($expression));
+
+lte
+---
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->lte('foo', 1);
+
+ $collection->matching(new Criteria($expression));
+
+neq
+---
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->neq('foo', 1);
+
+ $collection->matching(new Criteria($expression));
+
+isNull
+------
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->isNull('foo');
+
+ $collection->matching(new Criteria($expression));
+
+in
+---
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->in('foo', ['value1', 'value2']);
+
+ $collection->matching(new Criteria($expression));
+
+notIn
+-----
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->notIn('foo', ['value1', 'value2']);
+
+ $collection->matching(new Criteria($expression));
+
+contains
+--------
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->contains('foo', 'value1');
+
+ $collection->matching(new Criteria($expression));
+
+memberOf
+--------
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->memberOf('foo', ['value1', 'value2']);
+
+ $collection->matching(new Criteria($expression));
+
+startsWith
+----------
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->startsWith('foo', 'hello');
+
+ $collection->matching(new Criteria($expression));
+
+endsWith
+--------
+
+.. code-block:: php
+ $expressionBuilder = Criteria::expr();
+
+ $expression = $expressionBuilder->endsWith('foo', 'world');
+
+ $collection->matching(new Criteria($expression));
diff --git a/vendor/doctrine/collections/docs/en/expressions.rst b/vendor/doctrine/collections/docs/en/expressions.rst
new file mode 100644
index 0000000..db943b2
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/expressions.rst
@@ -0,0 +1,102 @@
+Expressions
+===========
+
+The ``Doctrine\Common\Collections\Expr\Comparison`` class
+can be used to create expressions to be used with the
+``Doctrine\Common\Collections\Criteria`` class. It has the
+following operator constants:
+
+- ``Comparison::EQ``
+- ``Comparison::NEQ``
+- ``Comparison::LT``
+- ``Comparison::LTE``
+- ``Comparison::GT``
+- ``Comparison::GTE``
+- ``Comparison::IS``
+- ``Comparison::IN``
+- ``Comparison::NIN``
+- ``Comparison::CONTAINS``
+- ``Comparison::MEMBER_OF``
+- ``Comparison::STARTS_WITH``
+- ``Comparison::ENDS_WITH``
+
+The ``Doctrine\Common\Collections\Criteria`` class has the following
+API to be used with expressions:
+
+where
+-----
+
+Sets the where expression to evaluate when this Criteria is searched for.
+
+.. code-block:: php
+ $expr = new Comparison('key', Comparison::EQ, 'value');
+
+ $criteria->where($expr);
+
+andWhere
+--------
+
+Appends the where expression to evaluate when this Criteria is searched for
+using an AND with previous expression.
+
+.. code-block:: php
+ $expr = new Comparison('key', Comparison::EQ, 'value');
+
+ $criteria->andWhere($expr);
+
+orWhere
+-------
+
+Appends the where expression to evaluate when this Criteria is searched for
+using an OR with previous expression.
+
+.. code-block:: php
+ $expr1 = new Comparison('key', Comparison::EQ, 'value1');
+ $expr2 = new Comparison('key', Comparison::EQ, 'value2');
+
+ $criteria->where($expr1);
+ $criteria->orWhere($expr2);
+
+orderBy
+-------
+
+Sets the ordering of the result of this Criteria.
+
+.. code-block:: php
+ $criteria->orderBy(['name' => Criteria::ASC]);
+
+setFirstResult
+--------------
+
+Set the number of first result that this Criteria should return.
+
+.. code-block:: php
+ $criteria->setFirstResult(0);
+
+getFirstResult
+--------------
+
+Gets the current first result option of this Criteria.
+
+.. code-block:: php
+ $criteria->setFirstResult(10);
+
+ echo $criteria->getFirstResult(); // 10
+
+setMaxResults
+-------------
+
+Sets the max results that this Criteria should return.
+
+.. code-block:: php
+ $criteria->setMaxResults(20);
+
+getMaxResults
+-------------
+
+Gets the current max results option of this Criteria.
+
+.. code-block:: php
+ $criteria->setMaxResults(20);
+
+ echo $criteria->getMaxResults(); // 20
diff --git a/vendor/doctrine/collections/docs/en/index.rst b/vendor/doctrine/collections/docs/en/index.rst
new file mode 100644
index 0000000..8ca9722
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/index.rst
@@ -0,0 +1,333 @@
+Introduction
+============
+
+Doctrine Collections is a library that contains classes for working with
+arrays of data. Here is an example using the simple
+``Doctrine\Common\Collections\ArrayCollection`` class:
+
+.. code-block:: php
+ <?php
+
+ use Doctrine\Common\Collections\ArrayCollection;
+
+ $collection = new ArrayCollection([1, 2, 3]);
+
+ $filteredCollection = $collection->filter(function($element) {
+ return $element > 1;
+ }); // [2, 3]
+
+Collection Methods
+==================
+
+Doctrine Collections provides an interface named ``Doctrine\Common\Collections\Collection``
+that resembles the nature of a regular PHP array. That is,
+it is essentially an **ordered map** that can also be used
+like a list.
+
+A Collection has an internal iterator just like a PHP array. In addition,
+a Collection can be iterated with external iterators, which is preferable.
+To use an external iterator simply use the foreach language construct to
+iterate over the collection, which calls ``getIterator()`` internally, or
+explicitly retrieve an iterator though ``getIterator()`` which can then be
+used to iterate over the collection. You can not rely on the internal iterator
+of the collection being at a certain position unless you explicitly positioned it before.
+
+Methods that do not alter the collection or have template types
+appearing in invariant or contravariant positions are not directly
+defined in ``Doctrine\Common\Collections\Collection``, but are inherited
+from the ``Doctrine\Common\Collections\ReadableCollection`` interface.
+
+The methods available on the interface are:
+
+add
+---
+
+Adds an element at the end of the collection.
+
+.. code-block:: php
+ $collection->add('test');
+
+clear
+-----
+
+Clears the collection, removing all elements.
+
+.. code-block:: php
+ $collection->clear();
+
+contains
+--------
+
+Checks whether an element is contained in the collection. This is an O(n) operation, where n is the size of the collection.
+
+.. code-block:: php
+ $collection = new Collection(['test']);
+
+ $contains = $collection->contains('test'); // true
+
+containsKey
+-----------
+
+Checks whether the collection contains an element with the specified key/index.
+
+.. code-block:: php
+ $collection = new Collection(['test' => true]);
+
+ $contains = $collection->containsKey('test'); // true
+
+current
+-------
+
+Gets the element of the collection at the current iterator position.
+
+.. code-block:: php
+ $collection = new Collection(['first', 'second', 'third']);
+
+ $current = $collection->current(); // first
+
+get
+---
+
+Gets the element at the specified key/index.
+
+.. code-block:: php
+ $collection = new Collection([
+ 'key' => 'value',
+ ]);
+
+ $value = $collection->get('key'); // value
+
+getKeys
+-------
+
+Gets all keys/indices of the collection.
+
+.. code-block:: php
+ $collection = new Collection(['a', 'b', 'c']);
+
+ $keys = $collection->getKeys(); // [0, 1, 2]
+
+getValues
+---------
+
+Gets all values of the collection.
+
+.. code-block:: php
+ $collection = new Collection([
+ 'key1' => 'value1',
+ 'key2' => 'value2',
+ 'key3' => 'value3',
+ ]);
+
+ $values = $collection->getValues(); // ['value1', 'value2', 'value3']
+
+isEmpty
+-------
+
+Checks whether the collection is empty (contains no elements).
+
+.. code-block:: php
+ $collection = new Collection(['a', 'b', 'c']);
+
+ $isEmpty = $collection->isEmpty(); // false
+
+first
+-----
+
+Sets the internal iterator to the first element in the collection and returns this element.
+
+.. code-block:: php
+ $collection = new Collection(['first', 'second', 'third']);
+
+ $first = $collection->first(); // first
+
+exists
+------
+
+Tests for the existence of an element that satisfies the given predicate.
+
+.. code-block:: php
+ $collection = new Collection(['first', 'second', 'third']);
+
+ $exists = $collection->exists(function($key, $value) {
+ return $value === 'first';
+ }); // true
+
+filter
+------
+
+Returns all the elements of this collection for which your callback function returns `true`.
+The order and keys of the elements are preserved.
+
+.. code-block:: php
+ $collection = new ArrayCollection([1, 2, 3]);
+
+ $filteredCollection = $collection->filter(function($element) {
+ return $element > 1;
+ }); // [2, 3]
+
+forAll
+------
+
+Tests whether the given predicate holds for all elements of this collection.
+
+.. code-block:: php
+ $collection = new ArrayCollection([1, 2, 3]);
+
+ $forAll = $collection->forAll(function($key, $value) {
+ return $value > 1;
+ }); // false
+
+indexOf
+-------
+
+Gets the index/key of a given element. The comparison of two elements is strict, that means not only the value but also the type must match. For objects this means reference equality.
+
+.. code-block:: php
+ $collection = new ArrayCollection([1, 2, 3]);
+
+ $indexOf = $collection->indexOf(3); // 2
+
+key
+---
+
+Gets the key/index of the element at the current iterator position.
+
+.. code-block:: php
+ $collection = new ArrayCollection([1, 2, 3]);
+
+ $collection->next();
+
+ $key = $collection->key(); // 1
+
+last
+----
+
+Sets the internal iterator to the last element in the collection and returns this element.
+
+.. code-block:: php
+ $collection = new ArrayCollection([1, 2, 3]);
+
+ $last = $collection->last(); // 3
+
+map
+---
+
+Applies the given function to each element in the collection and returns a new collection with the elements returned by the function.
+
+.. code-block:: php
+ $collection = new ArrayCollection([1, 2, 3]);
+
+ $mappedCollection = $collection->map(function($value) {
+ return $value + 1;
+ }); // [2, 3, 4]
+
+next
+----
+
+Moves the internal iterator position to the next element and returns this element.
+
+.. code-block:: php
+ $collection = new ArrayCollection([1, 2, 3]);
+
+ $next = $collection->next(); // 2
+
+partition
+---------
+
+Partitions this collection in two collections according to a predicate. Keys are preserved in the resulting collections.
+
+.. code-block:: php
+ $collection = new ArrayCollection([1, 2, 3]);
+
+ $mappedCollection = $collection->partition(function($key, $value) {
+ return $value > 1
+ }); // [[2, 3], [1]]
+
+remove
+------
+
+Removes the element at the specified index from the collection.
+
+.. code-block:: php
+ $collection = new ArrayCollection([1, 2, 3]);
+
+ $collection->remove(0); // [2, 3]
+
+removeElement
+-------------
+
+Removes the specified element from the collection, if it is found.
+
+.. code-block:: php
+ $collection = new ArrayCollection([1, 2, 3]);
+
+ $collection->removeElement(3); // [1, 2]
+
+set
+---
+
+Sets an element in the collection at the specified key/index.
+
+.. code-block:: php
+ $collection = new ArrayCollection();
+
+ $collection->set('name', 'jwage');
+
+slice
+-----
+
+Extracts a slice of $length elements starting at position $offset from the Collection. If $length is null it returns all elements from $offset to the end of the Collection. Keys have to be preserved by this method. Calling this method will only return the selected slice and NOT change the elements contained in the collection slice is called on.
+
+.. code-block:: php
+ $collection = new ArrayCollection([0, 1, 2, 3, 4, 5]);
+
+ $slice = $collection->slice(1, 2); // [1, 2]
+
+toArray
+-------
+
+Gets a native PHP array representation of the collection.
+
+.. code-block:: php
+ $collection = new ArrayCollection([0, 1, 2, 3, 4, 5]);
+
+ $array = $collection->toArray(); // [0, 1, 2, 3, 4, 5]
+
+Selectable Methods
+==================
+
+Some Doctrine Collections, like ``Doctrine\Common\Collections\ArrayCollection``,
+implement an interface named ``Doctrine\Common\Collections\Selectable``
+that offers the usage of a powerful expressions API, where conditions
+can be applied to a collection to get a result with matching elements
+only.
+
+matching
+--------
+
+Selects all elements from a selectable that match the expression and
+returns a new collection containing these elements.
+
+.. code-block:: php
+ use Doctrine\Common\Collections\Criteria;
+ use Doctrine\Common\Collections\Expr\Comparison;
+
+ $collection = new ArrayCollection([
+ [
+ 'name' => 'jwage',
+ ],
+ [
+ 'name' => 'romanb',
+ ],
+ ]);
+
+ $expr = new Comparison('name', '=', 'jwage');
+
+ $criteria = new Criteria();
+
+ $criteria->where($expr);
+
+ $matched = $collection->matching($criteria); // ['jwage']
+
+You can read more about expressions :ref:`here <expressions>`.
diff --git a/vendor/doctrine/collections/docs/en/lazy-collections.rst b/vendor/doctrine/collections/docs/en/lazy-collections.rst
new file mode 100644
index 0000000..b9cafb6
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/lazy-collections.rst
@@ -0,0 +1,26 @@
+Lazy Collections
+================
+
+To create a lazy collection you can extend the
+``Doctrine\Common\Collections\AbstractLazyCollection`` class
+and define the ``doInitialize`` method. Here is an example where
+we lazily query the database for a collection of user records:
+
+.. code-block:: php
+ use Doctrine\DBAL\Connection;
+
+ class UsersLazyCollection extends AbstractLazyCollection
+ {
+ /** @var Connection */
+ private $connection;
+
+ public function __construct(Connection $connection)
+ {
+ $this->connection = $connection;
+ }
+
+ protected function doInitialize() : void
+ {
+ $this->collection = $this->connection->fetchAll('SELECT * FROM users');
+ }
+ }
diff --git a/vendor/doctrine/collections/docs/en/sidebar.rst b/vendor/doctrine/collections/docs/en/sidebar.rst
new file mode 100644
index 0000000..69279a0
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/sidebar.rst
@@ -0,0 +1,8 @@
+.. toctree::
+ :depth: 3
+
+ index
+ expressions
+ expression-builder
+ derived-collections
+ lazy-collections