Implemented by | yii\elasticsearch\ActiveFixture, yii\mongodb\ActiveFixture, yii\sphinx\ActiveFixture, yii\test\ActiveFixture, yii\test\ArrayFixture, yii\test\BaseActiveFixture |
---|---|
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/base/ArrayAccessTrait.php |
ArrayAccessTrait provides the implementation for IteratorAggregate, ArrayAccess and Countable.
Note that ArrayAccessTrait requires the class using it contain a property named data
which should be an array. The data will be exposed by ArrayAccessTrait to support accessing the class object like an array.
Method | Description | Defined By |
---|---|---|
count() | Returns the number of data items. | yii\base\ArrayAccessTrait |
getIterator() | Returns an iterator for traversing the data. | yii\base\ArrayAccessTrait |
offsetExists() | This method is required by the interface ArrayAccess. | yii\base\ArrayAccessTrait |
offsetGet() | This method is required by the interface ArrayAccess. | yii\base\ArrayAccessTrait |
offsetSet() | This method is required by the interface ArrayAccess. | yii\base\ArrayAccessTrait |
offsetUnset() | This method is required by the interface ArrayAccess. | yii\base\ArrayAccessTrait |
Returns the number of data items.
This method is required by Countable interface.
public integer count ( ) | ||
---|---|---|
return | integer |
Number of data elements. |
Returns an iterator for traversing the data.
This method is required by the SPL interface IteratorAggregate. It will be implicitly called when you use foreach
to traverse the collection.
public ArrayIterator getIterator ( ) | ||
---|---|---|
return | ArrayIterator |
An iterator for traversing the cookies in the collection. |
This method is required by the interface ArrayAccess.
public boolean offsetExists ( $offset ) | ||
---|---|---|
$offset | mixed |
The offset to check on |
This method is required by the interface ArrayAccess.
public mixed offsetGet ( $offset ) | ||
---|---|---|
$offset | integer |
The offset to retrieve element. |
return | mixed |
The element at the offset, null if no element is found at the offset |
This method is required by the interface ArrayAccess.
public void offsetSet ( $offset, $item ) | ||
---|---|---|
$offset | integer |
The offset to set element |
$item | mixed |
The element value |
This method is required by the interface ArrayAccess.
public void offsetUnset ( $offset ) | ||
---|---|---|
$offset | mixed |
The offset to unset element |
© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc-2.0/yii-base-arrayaccesstrait.html