HumHub Documentation (unofficial)

ArrayAccessTrait

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.

Tags
author

Qiang Xue qiang.xue@gmail.com

since
2.0

Table of Contents

Properties

$data  : array<string|int, mixed>

Methods

count()  : int
Returns the number of data items.
getIterator()  : ArrayIterator
Returns an iterator for traversing the data.
offsetExists()  : bool
This method is required by the interface [[\ArrayAccess]].
offsetGet()  : mixed
This method is required by the interface [[\ArrayAccess]].
offsetSet()  : mixed
This method is required by the interface [[\ArrayAccess]].
offsetUnset()  : mixed
This method is required by the interface [[\ArrayAccess]].

Properties

Methods

count()

Returns the number of data items.

public count() : int

This method is required by Countable interface.

Attributes
#[ReturnTypeWillChange]
Return values
int

number of data elements.

getIterator()

Returns an iterator for traversing the data.

public getIterator() : ArrayIterator

This method is required by the SPL interface [[\IteratorAggregate]]. It will be implicitly called when you use foreach to traverse the collection.

Attributes
#[ReturnTypeWillChange]
Return values
ArrayIterator

an iterator for traversing the cookies in the collection.

offsetExists()

This method is required by the interface [[\ArrayAccess]].

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed

the offset to check on

Attributes
#[ReturnTypeWillChange]
Return values
bool

offsetGet()

This method is required by the interface [[\ArrayAccess]].

public offsetGet(int $offset) : mixed
Parameters
$offset : int

the offset to retrieve element.

Attributes
#[ReturnTypeWillChange]
Return values
mixed

the element at the offset, null if no element is found at the offset

offsetSet()

This method is required by the interface [[\ArrayAccess]].

public offsetSet(int $offset, mixed $item) : mixed
Parameters
$offset : int

the offset to set element

$item : mixed

the element value

Attributes
#[ReturnTypeWillChange]

offsetUnset()

This method is required by the interface [[\ArrayAccess]].

public offsetUnset(mixed $offset) : mixed
Parameters
$offset : mixed

the offset to unset element

Attributes
#[ReturnTypeWillChange]

        
On this page

Search results