mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
b50a646a3f
Summary: Ref T13588. I pointed my local `php` at PHP 8.1 and this is what I've hit so far; all these cases seem very unlikely to have any subtle behavior. Test Plan: Ran various `arc` workflows under PHP 8.1. Maniphest Tasks: T13588 Differential Revision: https://secure.phabricator.com/D21742
90 lines
1.8 KiB
PHP
90 lines
1.8 KiB
PHP
<?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.
|
|
*/
|
|
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 )------------------------------------------------ */
|
|
|
|
|
|
#[\ReturnTypeWillChange]
|
|
public function count() {
|
|
return count($this->data);
|
|
}
|
|
|
|
|
|
/* -( Iterator Interface )------------------------------------------------- */
|
|
|
|
|
|
#[\ReturnTypeWillChange]
|
|
public function current() {
|
|
return current($this->data);
|
|
}
|
|
|
|
#[\ReturnTypeWillChange]
|
|
public function key() {
|
|
return key($this->data);
|
|
}
|
|
|
|
#[\ReturnTypeWillChange]
|
|
public function next() {
|
|
return next($this->data);
|
|
}
|
|
|
|
#[\ReturnTypeWillChange]
|
|
public function rewind() {
|
|
reset($this->data);
|
|
}
|
|
|
|
#[\ReturnTypeWillChange]
|
|
public function valid() {
|
|
return (key($this->data) !== null);
|
|
}
|
|
|
|
|
|
/* -( ArrayAccess Interface )---------------------------------------------- */
|
|
|
|
|
|
#[\ReturnTypeWillChange]
|
|
public function offsetExists($key) {
|
|
return array_key_exists($key, $this->data);
|
|
}
|
|
|
|
#[\ReturnTypeWillChange]
|
|
public function offsetGet($key) {
|
|
return $this->data[$key];
|
|
}
|
|
|
|
#[\ReturnTypeWillChange]
|
|
public function offsetSet($key, $value) {
|
|
$this->data[$key] = $value;
|
|
}
|
|
|
|
#[\ReturnTypeWillChange]
|
|
public function offsetUnset($key) {
|
|
unset($this->data[$key]);
|
|
}
|
|
|
|
}
|