Documentation

GenericArray extends AbstractArray
in package

`GenericArray` represents a standard array object.

Tags
extends

AbstractArray

Table of Contents

$data  : array<array-key, T>
The items of this array.
__construct()  : mixed
Constructs a new array object.
__serialize()  : array<array-key, T>
Returns data suitable for PHP serialization.
__unserialize()  : void
Adds unserialized data to the object.
clear()  : void
Removes all items from this array.
count()  : int
Returns the number of items in this array.
getIterator()  : Traversable<array-key, T>
Returns an iterator for this array.
isEmpty()  : bool
Returns `true` if this array is empty.
offsetExists()  : bool
Returns `true` if the given offset exists in this array.
offsetGet()  : T|null
Returns the value at the specified offset.
offsetSet()  : void
Sets the given value to the given offset in the array.
offsetUnset()  : void
Removes the given offset and its value from the array.
serialize()  : string
Returns a serialized string representation of this array object.
toArray()  : array<array-key, T>
Returns a native PHP array representation of this array object.
unserialize()  : void
Converts a serialized string representation into an instance object.

Properties

$data

The items of this array.

protected array<array-key, T> $data = []

Methods

__construct()

Constructs a new array object.

public __construct([array<array-key, T$data = [] ]) : mixed
Parameters
$data : array<array-key, T> = []

The initial items to add to this array.

Return values
mixed

__unserialize()

Adds unserialized data to the object.

public __unserialize(array<array-key, T$data) : void
Parameters
$data : array<array-key, T>
Return values
void

clear()

Removes all items from this array.

public clear() : void
Return values
void

isEmpty()

Returns `true` if this array is empty.

public isEmpty() : bool
Return values
bool

offsetExists()

Returns `true` if the given offset exists in this array.

public offsetExists(string|int $offset) : bool
Parameters
$offset : string|int

The offset to check.

Tags
link

ArrayAccess::offsetExists()

Return values
bool

offsetGet()

Returns the value at the specified offset.

public offsetGet(string|int $offset) : T|null
Parameters
$offset : string|int

The offset for which a value should be returned.

Tags
link

ArrayAccess::offsetGet()

psalm-suppress

InvalidAttribute

Return values
T|null

the value stored at the offset, or null if the offset does not exist.

offsetSet()

Sets the given value to the given offset in the array.

public offsetSet(string|int|null $offset, T $value) : void
Parameters
$offset : string|int|null

The offset to set. If null, the value may be set at a numerically-indexed offset.

$value : T

The value to set at the given offset.

Tags
link

ArrayAccess::offsetSet()

Return values
void

offsetUnset()

Removes the given offset and its value from the array.

public offsetUnset(string|int $offset) : void
Parameters
$offset : string|int

The offset to remove from the array.

Tags
link

ArrayAccess::offsetUnset()

Return values
void

serialize()

Returns a serialized string representation of this array object.

public serialize() : string
Tags
deprecated

The Serializable interface will go away in PHP 9.

link

Serializable::serialize()

Return values
string

a PHP serialized string.

toArray()

Returns a native PHP array representation of this array object.

public toArray() : array<array-key, T>
Tags
inheritDoc
Return values
array<array-key, T>

unserialize()

Converts a serialized string representation into an instance object.

public unserialize(string $serialized) : void
Parameters
$serialized : string

A PHP serialized string to unserialize.

Tags
deprecated

The Serializable interface will go away in PHP 9.

link

Serializable::unserialize()

phpcsSuppress

SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint

Return values
void

Search results