Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90818903
PhutilArray.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 5, 01:35
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Nov 7, 01:35 (2 d)
Engine
blob
Format
Raw Data
Handle
22140241
Attached To
rPHU libphutil
PhutilArray.php
View Options
<?php
/**
* Abstract base class for implementing objects that behave like arrays. This
* class wraps a basic array and provides trivial implementations for
* `Countable`, `ArrayAccess` and `Iterator`, so subclasses need only implement
* specializations.
*
* @group util
*/
abstract
class
PhutilArray
extends
Phobject
implements
Countable
,
ArrayAccess
,
Iterator
{
protected
$data
=
array
();
public
function
__construct
(
array
$initial_value
=
array
())
{
$this
->
data
=
$initial_value
;
}
/* -( Conversion )--------------------------------------------------------- */
public
function
toArray
()
{
return
iterator_to_array
(
$this
,
true
);
}
/* -( Countable Interface )------------------------------------------------ */
public
function
count
()
{
return
count
(
$this
->
data
);
}
/* -( Iterator Interface )------------------------------------------------- */
public
function
current
()
{
return
current
(
$this
->
data
);
}
public
function
key
()
{
return
key
(
$this
->
data
);
}
public
function
next
()
{
return
next
(
$this
->
data
);
}
public
function
rewind
()
{
reset
(
$this
->
data
);
}
public
function
valid
()
{
return
(
key
(
$this
->
data
)
!==
null
);
}
/* -( ArrayAccess Interface )---------------------------------------------- */
public
function
offsetExists
(
$key
)
{
return
array_key_exists
(
$key
,
$this
->
data
);
}
public
function
offsetGet
(
$key
)
{
return
$this
->
data
[
$key
];
}
public
function
offsetSet
(
$key
,
$value
)
{
$this
->
data
[
$key
]
=
$value
;
}
public
function
offsetUnset
(
$key
)
{
unset
(
$this
->
data
[
$key
]);
}
}
Event Timeline
Log In to Comment