summaryrefslogtreecommitdiff
path: root/vendor/doctrine/collections/docs/en
diff options
context:
space:
mode:
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.rst185
-rw-r--r--vendor/doctrine/collections/docs/en/expressions.rst117
-rw-r--r--vendor/doctrine/collections/docs/en/index.rst357
-rw-r--r--vendor/doctrine/collections/docs/en/lazy-collections.rst26
-rw-r--r--vendor/doctrine/collections/docs/en/serialization.rst29
-rw-r--r--vendor/doctrine/collections/docs/en/sidebar.rst11
7 files changed, 751 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 @@
1Derived Collections
2===================
3
4You can create custom collection classes by extending the
5``Doctrine\Common\Collections\ArrayCollection`` class. If the
6``__construct`` semantics are different from the default ``ArrayCollection``
7you can override the ``createFrom`` method:
8
9.. code-block:: php
10 final class DerivedArrayCollection extends ArrayCollection
11 {
12 /** @var \stdClass */
13 private $foo;
14
15 public function __construct(\stdClass $foo, array $elements = [])
16 {
17 $this->foo = $foo;
18
19 parent::__construct($elements);
20 }
21
22 protected function createFrom(array $elements) : self
23 {
24 return new static($this->foo, $elements);
25 }
26 }
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..e022441
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/expression-builder.rst
@@ -0,0 +1,185 @@
1Expression Builder
2==================
3
4The Expression Builder is a convenient fluent interface for
5building expressions to be used with the ``Doctrine\Common\Collections\Criteria``
6class:
7
8.. code-block:: php
9 $expressionBuilder = Criteria::expr();
10
11 $criteria = new Criteria();
12 $criteria->where($expressionBuilder->eq('name', 'jwage'));
13 $criteria->orWhere($expressionBuilder->eq('name', 'romanb'));
14
15 $collection->matching($criteria);
16
17The ``ExpressionBuilder`` has the following API:
18
19andX
20----
21
22.. code-block:: php
23 $expressionBuilder = Criteria::expr();
24
25 $expression = $expressionBuilder->andX(
26 $expressionBuilder->eq('foo', 1),
27 $expressionBuilder->eq('bar', 1)
28 );
29
30 $collection->matching(new Criteria($expression));
31
32orX
33---
34
35.. code-block:: php
36 $expressionBuilder = Criteria::expr();
37
38 $expression = $expressionBuilder->orX(
39 $expressionBuilder->eq('foo', 1),
40 $expressionBuilder->eq('bar', 1)
41 );
42
43 $collection->matching(new Criteria($expression));
44
45not
46---
47
48.. code-block:: php
49 $expressionBuilder = Criteria::expr();
50
51 $expression = $expressionBuilder->not(
52 $expressionBuilder->eq('foo', 1)
53 );
54
55 $collection->matching(new Criteria($expression));
56
57eq
58---
59
60.. code-block:: php
61 $expressionBuilder = Criteria::expr();
62
63 $expression = $expressionBuilder->eq('foo', 1);
64
65 $collection->matching(new Criteria($expression));
66
67gt
68---
69
70.. code-block:: php
71 $expressionBuilder = Criteria::expr();
72
73 $expression = $expressionBuilder->gt('foo', 1);
74
75 $collection->matching(new Criteria($expression));
76
77lt
78---
79
80.. code-block:: php
81 $expressionBuilder = Criteria::expr();
82
83 $expression = $expressionBuilder->lt('foo', 1);
84
85 $collection->matching(new Criteria($expression));
86
87gte
88---
89
90.. code-block:: php
91 $expressionBuilder = Criteria::expr();
92
93 $expression = $expressionBuilder->gte('foo', 1);
94
95 $collection->matching(new Criteria($expression));
96
97lte
98---
99
100.. code-block:: php
101 $expressionBuilder = Criteria::expr();
102
103 $expression = $expressionBuilder->lte('foo', 1);
104
105 $collection->matching(new Criteria($expression));
106
107neq
108---
109
110.. code-block:: php
111 $expressionBuilder = Criteria::expr();
112
113 $expression = $expressionBuilder->neq('foo', 1);
114
115 $collection->matching(new Criteria($expression));
116
117isNull
118------
119
120.. code-block:: php
121 $expressionBuilder = Criteria::expr();
122
123 $expression = $expressionBuilder->isNull('foo');
124
125 $collection->matching(new Criteria($expression));
126
127in
128---
129
130.. code-block:: php
131 $expressionBuilder = Criteria::expr();
132
133 $expression = $expressionBuilder->in('foo', ['value1', 'value2']);
134
135 $collection->matching(new Criteria($expression));
136
137notIn
138-----
139
140.. code-block:: php
141 $expressionBuilder = Criteria::expr();
142
143 $expression = $expressionBuilder->notIn('foo', ['value1', 'value2']);
144
145 $collection->matching(new Criteria($expression));
146
147contains
148--------
149
150.. code-block:: php
151 $expressionBuilder = Criteria::expr();
152
153 $expression = $expressionBuilder->contains('foo', 'value1');
154
155 $collection->matching(new Criteria($expression));
156
157memberOf
158--------
159
160.. code-block:: php
161 $expressionBuilder = Criteria::expr();
162
163 $expression = $expressionBuilder->memberOf('foo', ['value1', 'value2']);
164
165 $collection->matching(new Criteria($expression));
166
167startsWith
168----------
169
170.. code-block:: php
171 $expressionBuilder = Criteria::expr();
172
173 $expression = $expressionBuilder->startsWith('foo', 'hello');
174
175 $collection->matching(new Criteria($expression));
176
177endsWith
178--------
179
180.. code-block:: php
181 $expressionBuilder = Criteria::expr();
182
183 $expression = $expressionBuilder->endsWith('foo', 'world');
184
185 $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..5587bfb
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/expressions.rst
@@ -0,0 +1,117 @@
1Expressions
2===========
3
4The ``Doctrine\Common\Collections\Expr\Comparison`` class
5can be used to create comparison expressions to be used with the
6``Doctrine\Common\Collections\Criteria`` class. It has the
7following operator constants:
8
9- ``Comparison::EQ``
10- ``Comparison::NEQ``
11- ``Comparison::LT``
12- ``Comparison::LTE``
13- ``Comparison::GT``
14- ``Comparison::GTE``
15- ``Comparison::IS``
16- ``Comparison::IN``
17- ``Comparison::NIN``
18- ``Comparison::CONTAINS``
19- ``Comparison::MEMBER_OF``
20- ``Comparison::STARTS_WITH``
21- ``Comparison::ENDS_WITH``
22
23The ``Doctrine\Common\Collections\Expr\CompositeExpression`` class
24can be used to create composite expressions to be used with the
25``Doctrine\Common\Collections\Criteria`` class. It has the
26following operator constants:
27
28- ``CompositeExpression::TYPE_AND``
29- ``CompositeExpression::TYPE_OR``
30- ``CompositeExpression::TYPE_NOT``
31
32When using the ``TYPE_OR`` and ``TYPE_AND`` operators the
33``CompositeExpression`` accepts multiple expressions as parameter
34but only one expression can be provided when using the ``NOT`` operator.
35
36The ``Doctrine\Common\Collections\Criteria`` class has the following
37API to be used with expressions:
38
39where
40-----
41
42Sets the where expression to evaluate when this Criteria is searched for.
43
44.. code-block:: php
45 $expr = new Comparison('key', Comparison::EQ, 'value');
46
47 $criteria->where($expr);
48
49andWhere
50--------
51
52Appends the where expression to evaluate when this Criteria is searched for
53using an AND with previous expression.
54
55.. code-block:: php
56 $expr = new Comparison('key', Comparison::EQ, 'value');
57
58 $criteria->andWhere($expr);
59
60orWhere
61-------
62
63Appends the where expression to evaluate when this Criteria is searched for
64using an OR with previous expression.
65
66.. code-block:: php
67 $expr1 = new Comparison('key', Comparison::EQ, 'value1');
68 $expr2 = new Comparison('key', Comparison::EQ, 'value2');
69
70 $criteria->where($expr1);
71 $criteria->orWhere($expr2);
72
73orderBy
74-------
75
76Sets the ordering of the result of this Criteria.
77
78.. code-block:: php
79 use Doctrine\Common\Collections\Order;
80
81 $criteria->orderBy(['name' => Order::Ascending]);
82
83setFirstResult
84--------------
85
86Set the number of first result that this Criteria should return.
87
88.. code-block:: php
89 $criteria->setFirstResult(0);
90
91getFirstResult
92--------------
93
94Gets the current first result option of this Criteria.
95
96.. code-block:: php
97 $criteria->setFirstResult(10);
98
99 echo $criteria->getFirstResult(); // 10
100
101setMaxResults
102-------------
103
104Sets the max results that this Criteria should return.
105
106.. code-block:: php
107 $criteria->setMaxResults(20);
108
109getMaxResults
110-------------
111
112Gets the current max results option of this Criteria.
113
114.. code-block:: php
115 $criteria->setMaxResults(20);
116
117 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..7f2e38c
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/index.rst
@@ -0,0 +1,357 @@
1Introduction
2============
3
4Doctrine Collections is a library that contains classes for working with
5arrays of data. Here is an example using the simple
6``Doctrine\Common\Collections\ArrayCollection`` class:
7
8.. code-block:: php
9 <?php
10
11 use Doctrine\Common\Collections\ArrayCollection;
12
13 $collection = new ArrayCollection([1, 2, 3]);
14
15 $filteredCollection = $collection->filter(function($element) {
16 return $element > 1;
17 }); // [2, 3]
18
19Collection Methods
20==================
21
22Doctrine Collections provides an interface named ``Doctrine\Common\Collections\Collection``
23that resembles the nature of a regular PHP array. That is,
24it is essentially an **ordered map** that can also be used
25like a list.
26
27A Collection has an internal iterator just like a PHP array. In addition,
28a Collection can be iterated with external iterators, which is preferable.
29To use an external iterator simply use the foreach language construct to
30iterate over the collection, which calls ``getIterator()`` internally, or
31explicitly retrieve an iterator though ``getIterator()`` which can then be
32used to iterate over the collection. You can not rely on the internal iterator
33of the collection being at a certain position unless you explicitly positioned it before.
34
35Methods that do not alter the collection or have template types
36appearing in invariant or contravariant positions are not directly
37defined in ``Doctrine\Common\Collections\Collection``, but are inherited
38from the ``Doctrine\Common\Collections\ReadableCollection`` interface.
39
40The methods available on the interface are:
41
42add
43---
44
45Adds an element at the end of the collection.
46
47.. code-block:: php
48 $collection->add('test');
49
50clear
51-----
52
53Clears the collection, removing all elements.
54
55.. code-block:: php
56 $collection->clear();
57
58contains
59--------
60
61Checks whether an element is contained in the collection. This is an O(n) operation, where n is the size of the collection.
62
63.. code-block:: php
64 $collection = new Collection(['test']);
65
66 $contains = $collection->contains('test'); // true
67
68containsKey
69-----------
70
71Checks whether the collection contains an element with the specified key/index.
72
73.. code-block:: php
74 $collection = new Collection(['test' => true]);
75
76 $contains = $collection->containsKey('test'); // true
77
78current
79-------
80
81Gets the element of the collection at the current iterator position.
82
83.. code-block:: php
84 $collection = new Collection(['first', 'second', 'third']);
85
86 $current = $collection->current(); // first
87
88get
89---
90
91Gets the element at the specified key/index.
92
93.. code-block:: php
94 $collection = new Collection([
95 'key' => 'value',
96 ]);
97
98 $value = $collection->get('key'); // value
99
100getKeys
101-------
102
103Gets all keys/indices of the collection.
104
105.. code-block:: php
106 $collection = new Collection(['a', 'b', 'c']);
107
108 $keys = $collection->getKeys(); // [0, 1, 2]
109
110getValues
111---------
112
113Gets all values of the collection.
114
115.. code-block:: php
116 $collection = new Collection([
117 'key1' => 'value1',
118 'key2' => 'value2',
119 'key3' => 'value3',
120 ]);
121
122 $values = $collection->getValues(); // ['value1', 'value2', 'value3']
123
124isEmpty
125-------
126
127Checks whether the collection is empty (contains no elements).
128
129.. code-block:: php
130 $collection = new Collection(['a', 'b', 'c']);
131
132 $isEmpty = $collection->isEmpty(); // false
133
134first
135-----
136
137Sets the internal iterator to the first element in the collection and returns this element.
138
139.. code-block:: php
140 $collection = new Collection(['first', 'second', 'third']);
141
142 $first = $collection->first(); // first
143
144exists
145------
146
147Tests for the existence of an element that satisfies the given predicate.
148
149.. code-block:: php
150 $collection = new Collection(['first', 'second', 'third']);
151
152 $exists = $collection->exists(function($key, $value) {
153 return $value === 'first';
154 }); // true
155
156findFirst
157---------
158
159Returns the first element of this collection that satisfies the given predicate.
160
161.. code-block:: php
162 $collection = new Collection([1, 2, 3, 2, 1]);
163
164 $one = $collection->findFirst(function(int $key, int $value): bool {
165 return $value > 2 && $key > 1;
166 }); // 3
167
168filter
169------
170
171Returns all the elements of this collection for which your callback function returns `true`.
172The order and keys of the elements are preserved.
173
174.. code-block:: php
175 $collection = new ArrayCollection([1, 2, 3]);
176
177 $filteredCollection = $collection->filter(function($element) {
178 return $element > 1;
179 }); // [2, 3]
180
181forAll
182------
183
184Tests whether the given predicate holds for all elements of this collection.
185
186.. code-block:: php
187 $collection = new ArrayCollection([1, 2, 3]);
188
189 $forAll = $collection->forAll(function($key, $value) {
190 return $value > 1;
191 }); // false
192
193indexOf
194-------
195
196Gets 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.
197
198.. code-block:: php
199 $collection = new ArrayCollection([1, 2, 3]);
200
201 $indexOf = $collection->indexOf(3); // 2
202
203key
204---
205
206Gets the key/index of the element at the current iterator position.
207
208.. code-block:: php
209 $collection = new ArrayCollection([1, 2, 3]);
210
211 $collection->next();
212
213 $key = $collection->key(); // 1
214
215last
216----
217
218Sets the internal iterator to the last element in the collection and returns this element.
219
220.. code-block:: php
221 $collection = new ArrayCollection([1, 2, 3]);
222
223 $last = $collection->last(); // 3
224
225map
226---
227
228Applies the given function to each element in the collection and returns a new collection with the elements returned by the function.
229
230.. code-block:: php
231 $collection = new ArrayCollection([1, 2, 3]);
232
233 $mappedCollection = $collection->map(function($value) {
234 return $value + 1;
235 }); // [2, 3, 4]
236
237reduce
238------
239
240Applies iteratively the given function to each element in the collection, so as to reduce the collection to a single value.
241
242.. code-block:: php
243 $collection = new ArrayCollection([1, 2, 3]);
244
245 $reduce = $collection->reduce(function(int $accumulator, int $value): int {
246 return $accumulator + $value;
247 }, 0); // 6
248
249next
250----
251
252Moves the internal iterator position to the next element and returns this element.
253
254.. code-block:: php
255 $collection = new ArrayCollection([1, 2, 3]);
256
257 $next = $collection->next(); // 2
258
259partition
260---------
261
262Partitions this collection in two collections according to a predicate. Keys are preserved in the resulting collections.
263
264.. code-block:: php
265 $collection = new ArrayCollection([1, 2, 3]);
266
267 $mappedCollection = $collection->partition(function($key, $value) {
268 return $value > 1
269 }); // [[2, 3], [1]]
270
271remove
272------
273
274Removes the element at the specified index from the collection.
275
276.. code-block:: php
277 $collection = new ArrayCollection([1, 2, 3]);
278
279 $collection->remove(0); // [2, 3]
280
281removeElement
282-------------
283
284Removes the specified element from the collection, if it is found.
285
286.. code-block:: php
287 $collection = new ArrayCollection([1, 2, 3]);
288
289 $collection->removeElement(3); // [1, 2]
290
291set
292---
293
294Sets an element in the collection at the specified key/index.
295
296.. code-block:: php
297 $collection = new ArrayCollection();
298
299 $collection->set('name', 'jwage');
300
301slice
302-----
303
304Extracts 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.
305
306.. code-block:: php
307 $collection = new ArrayCollection([0, 1, 2, 3, 4, 5]);
308
309 $slice = $collection->slice(1, 2); // [1, 2]
310
311toArray
312-------
313
314Gets a native PHP array representation of the collection.
315
316.. code-block:: php
317 $collection = new ArrayCollection([0, 1, 2, 3, 4, 5]);
318
319 $array = $collection->toArray(); // [0, 1, 2, 3, 4, 5]
320
321Selectable Methods
322==================
323
324Some Doctrine Collections, like ``Doctrine\Common\Collections\ArrayCollection``,
325implement an interface named ``Doctrine\Common\Collections\Selectable``
326that offers the usage of a powerful expressions API, where conditions
327can be applied to a collection to get a result with matching elements
328only.
329
330matching
331--------
332
333Selects all elements from a selectable that match the expression and
334returns a new collection containing these elements and preserved keys.
335
336.. code-block:: php
337 use Doctrine\Common\Collections\Criteria;
338 use Doctrine\Common\Collections\Expr\Comparison;
339
340 $collection = new ArrayCollection([
341 'wage' => [
342 'name' => 'jwage',
343 ],
344 'roman' => [
345 'name' => 'romanb',
346 ],
347 ]);
348
349 $expr = new Comparison('name', '=', 'jwage');
350
351 $criteria = new Criteria();
352
353 $criteria->where($expr);
354
355 $matchingCollection = $collection->matching($criteria); // [ 'wage' => [ 'name' => 'jwage' ]]
356
357You 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 @@
1Lazy Collections
2================
3
4To create a lazy collection you can extend the
5``Doctrine\Common\Collections\AbstractLazyCollection`` class
6and define the ``doInitialize`` method. Here is an example where
7we lazily query the database for a collection of user records:
8
9.. code-block:: php
10 use Doctrine\DBAL\Connection;
11
12 class UsersLazyCollection extends AbstractLazyCollection
13 {
14 /** @var Connection */
15 private $connection;
16
17 public function __construct(Connection $connection)
18 {
19 $this->connection = $connection;
20 }
21
22 protected function doInitialize() : void
23 {
24 $this->collection = $this->connection->fetchAll('SELECT * FROM users');
25 }
26 }
diff --git a/vendor/doctrine/collections/docs/en/serialization.rst b/vendor/doctrine/collections/docs/en/serialization.rst
new file mode 100644
index 0000000..be53d6e
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/serialization.rst
@@ -0,0 +1,29 @@
1Serialization
2=============
3
4Using (un-)serialize() on a collection is not a supported use-case
5and may break when changes on the collection's internals happen in the future.
6If a collection needs to be serialized, use ``toArray()`` and reconstruct
7the collection manually.
8
9.. code-block:: php
10
11 $collection = new ArrayCollection([1, 2, 3]);
12 $serialized = serialize($collection->toArray());
13
14A reconstruction is also necessary when the collection contains objects with
15infinite recursion of dependencies like in this ``json_serialize()`` example:
16
17.. code-block:: php
18
19 $foo = new Foo();
20 $bar = new Bar();
21
22 $foo->setBar($bar);
23 $bar->setFoo($foo);
24
25 $collection = new ArrayCollection([$foo]);
26 $json = json_serialize($collection->toArray()); // recursion detected
27
28Serializer libraries can be used to create the serialization-output to prevent
29errors.
diff --git a/vendor/doctrine/collections/docs/en/sidebar.rst b/vendor/doctrine/collections/docs/en/sidebar.rst
new file mode 100644
index 0000000..ebfb11c
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/sidebar.rst
@@ -0,0 +1,11 @@
1:orphan:
2
3.. toctree::
4 :depth: 3
5
6 index
7 expressions
8 expression-builder
9 derived-collections
10 lazy-collections
11 serialization