<TKey is array-key, T>extends |
ReadableCollection<TKey, T>, ArrayAccess<TKey, T> |
|---|
The missing (SPL) Collection/Array/OrderedMap interface.
A Collection 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 {@link getIterator()} internally) or explicitly retrieve an iterator though {@link 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. Prefer iteration with external iterators.
| Methods | ||
|---|---|---|
public
|
add(T $element): void
|
# |
public
|
clear(): void
|
# |
public
|
remove(TKey $key): mixed
|
# |
public
|
removeElement(T $element): bool
|
# |
public
|
set(TKey $key, T $value): void
|
# |
public
|
map<U>(Closure(T): U $func): Collection<mixed>
|
# |
public
|
filter(Closure $p): Collection<mixed>
|
# |
public
|
partition(Closure $p): Collection<mixed>[]
|
# |
| Methods inherited from Doctrine\Common\Collections\ReadableCollection |
|---|
contains(), isEmpty(), containsKey(), get(), getKeys(), getValues(), toArray(), first(), last(), key(), current(), next(), slice(), exists(), forAll(), indexOf(), findFirst(), reduce() |
| Methods inherited from Countable |
|---|
count() |
| Methods inherited from IteratorAggregate |
|---|
getIterator() |
| Methods inherited from ArrayAccess |
|---|
offsetExists(), offsetGet(), offsetSet(), offsetUnset() |