MediaWiki REL1_40
GenericArrayObject Class Reference

Extends ArrayObject and does two things: More...

Inherits ArrayObject.

Inherited by SiteList.

Collaboration diagram for GenericArrayObject:

Public Member Functions

 __construct ( $input=null, $flags=0, $iterator_class='ArrayIterator')
 
 __serialize ()
 
 __unserialize ( $serializationData)
 
 append ( $value)
 
 getObjectType ()
 Returns the name of an interface/class that the element should implement/extend.
 
 isEmpty ()
 Returns if the ArrayObject has no elements.
 
 offsetSet ( $index, $value)
 

Protected Member Functions

 getNewOffset ()
 Finds a new offset for when appending an element.
 
 getSerializationData ()
 Returns an array holding all the data that should go into serialization calls.
 
 hasValidType ( $value)
 Returns if the provided value has the same type as the elements that can be added to this ArrayObject.
 
 preSetElement ( $index, $value)
 Gets called before a new element is added to the ArrayObject.
 
 setElement ( $index, $value)
 Method that actually sets the element and holds all common code needed for set operations, including type checking and offset resolving.
 

Protected Attributes

int $indexOffset = 0
 

Detailed Description

Extends ArrayObject and does two things:

Allows for deriving classes to easily intercept additions and deletions for purposes such as additional indexing.

Enforces the objects to be of a certain type, so this can be replied upon, much like if this had true support for generics, which sadly enough is not possible in PHP.

Deprecated
since 1.40 Use built-in ArrayObject instead.
Since
1.20
Note
GPL-2.0-or-later
Author
Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >

Definition at line 36 of file GenericArrayObject.php.

Constructor & Destructor Documentation

◆ __construct()

GenericArrayObject::__construct ( $input = null,
$flags = 0,
$iterator_class = 'ArrayIterator' )
See also
ArrayObject::__construct
Since
1.20
Parameters
null | array$input
int$flags
string$iterator_class

Definition at line 79 of file GenericArrayObject.php.

References offsetSet(), and wfDeprecated().

Member Function Documentation

◆ __serialize()

GenericArrayObject::__serialize ( )
See also
Serializable::serialize
Since
1.38
Returns
array

Definition at line 189 of file GenericArrayObject.php.

◆ __unserialize()

GenericArrayObject::__unserialize ( $serializationData)
See also
Serializable::unserialize
Since
1.38
Parameters
array$serializationData

Reimplemented in SiteList.

Definition at line 216 of file GenericArrayObject.php.

◆ append()

GenericArrayObject::append ( $value)
See also
ArrayObject::append
Since
1.20
Parameters
mixed$value

Definition at line 100 of file GenericArrayObject.php.

◆ getNewOffset()

GenericArrayObject::getNewOffset ( )
protected

Finds a new offset for when appending an element.

The base class does this, so it would be better to integrate, but there does not appear to be any way to do this...

Since
1.20
Returns
int

Definition at line 62 of file GenericArrayObject.php.

References $indexOffset.

◆ getObjectType()

GenericArrayObject::getObjectType ( )
abstract

Returns the name of an interface/class that the element should implement/extend.

Since
1.20
Returns
string

Reimplemented in SiteList.

◆ getSerializationData()

GenericArrayObject::getSerializationData ( )
protected

Returns an array holding all the data that should go into serialization calls.

This is intended to allow overloading without having to reimplement the behavior of this base class.

Since
1.20
Returns
array

Reimplemented in SiteList.

Definition at line 202 of file GenericArrayObject.php.

◆ hasValidType()

GenericArrayObject::hasValidType ( $value)
protected

Returns if the provided value has the same type as the elements that can be added to this ArrayObject.

Since
1.20
Parameters
mixed$value
Returns
bool

Definition at line 126 of file GenericArrayObject.php.

◆ isEmpty()

GenericArrayObject::isEmpty ( )

Returns if the ArrayObject has no elements.

Since
1.20
Returns
bool

Reimplemented in SiteList.

Definition at line 233 of file GenericArrayObject.php.

◆ offsetSet()

GenericArrayObject::offsetSet ( $index,
$value )
See also
ArrayObject::offsetSet()
Since
1.20
Parameters
mixed$index
mixed$value

Definition at line 112 of file GenericArrayObject.php.

Referenced by __construct().

◆ preSetElement()

GenericArrayObject::preSetElement ( $index,
$value )
protected

Gets called before a new element is added to the ArrayObject.

At this point the index is always set (ie not null) and the value is always of the type returned by

See also
getObjectType.

Should return a boolean. When false is returned the element does not get added to the ArrayObject.

Since
1.20
Parameters
int | string$index
mixed$value
Returns
bool

Reimplemented in SiteList.

Definition at line 178 of file GenericArrayObject.php.

◆ setElement()

GenericArrayObject::setElement ( $index,
$value )
protected

Method that actually sets the element and holds all common code needed for set operations, including type checking and offset resolving.

If you want to do additional indexing or have code that otherwise needs to be executed whenever an element is added, you can overload

See also
preSetElement.
Since
1.20
Parameters
mixed$index
mixed$value
Exceptions
InvalidArgumentException

Definition at line 147 of file GenericArrayObject.php.

Member Data Documentation

◆ $indexOffset

int GenericArrayObject::$indexOffset = 0
protected
See also
SiteList::getNewOffset()
Since
1.20

Definition at line 51 of file GenericArrayObject.php.

Referenced by getNewOffset().


The documentation for this class was generated from the following file: