Edit File by line
/home/barbar84/public_h.../wp-inclu.../sodium_c.../src/PHP52
File: SplFixedArray.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if (class_exists('SplFixedArray')) {
[2] Fix | Delete
return;
[3] Fix | Delete
}
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* The SplFixedArray class provides the main functionalities of array. The
[7] Fix | Delete
* main differences between a SplFixedArray and a normal PHP array is that
[8] Fix | Delete
* the SplFixedArray is of fixed length and allows only integers within
[9] Fix | Delete
* the range as indexes. The advantage is that it allows a faster array
[10] Fix | Delete
* implementation.
[11] Fix | Delete
*/
[12] Fix | Delete
class SplFixedArray implements Iterator, ArrayAccess, Countable
[13] Fix | Delete
{
[14] Fix | Delete
/** @var array<int, mixed> */
[15] Fix | Delete
private $internalArray = array();
[16] Fix | Delete
[17] Fix | Delete
/** @var int $size */
[18] Fix | Delete
private $size = 0;
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* SplFixedArray constructor.
[22] Fix | Delete
* @param int $size
[23] Fix | Delete
*/
[24] Fix | Delete
public function __construct($size = 0)
[25] Fix | Delete
{
[26] Fix | Delete
$this->size = $size;
[27] Fix | Delete
$this->internalArray = array();
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* @return int
[32] Fix | Delete
*/
[33] Fix | Delete
public function count()
[34] Fix | Delete
{
[35] Fix | Delete
return count($this->internalArray);
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* @return array
[40] Fix | Delete
*/
[41] Fix | Delete
public function toArray()
[42] Fix | Delete
{
[43] Fix | Delete
ksort($this->internalArray);
[44] Fix | Delete
return (array) $this->internalArray;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* @param array $array
[49] Fix | Delete
* @param bool $save_indexes
[50] Fix | Delete
* @return SplFixedArray
[51] Fix | Delete
* @psalm-suppress MixedAssignment
[52] Fix | Delete
*/
[53] Fix | Delete
public static function fromArray(array $array, $save_indexes = true)
[54] Fix | Delete
{
[55] Fix | Delete
$self = new SplFixedArray(count($array));
[56] Fix | Delete
if($save_indexes) {
[57] Fix | Delete
foreach($array as $key => $value) {
[58] Fix | Delete
$self[(int) $key] = $value;
[59] Fix | Delete
}
[60] Fix | Delete
} else {
[61] Fix | Delete
$i = 0;
[62] Fix | Delete
foreach (array_values($array) as $value) {
[63] Fix | Delete
$self[$i] = $value;
[64] Fix | Delete
$i++;
[65] Fix | Delete
}
[66] Fix | Delete
}
[67] Fix | Delete
return $self;
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* @return int
[72] Fix | Delete
*/
[73] Fix | Delete
public function getSize()
[74] Fix | Delete
{
[75] Fix | Delete
return $this->size;
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* @param int $size
[80] Fix | Delete
* @return bool
[81] Fix | Delete
*/
[82] Fix | Delete
public function setSize($size)
[83] Fix | Delete
{
[84] Fix | Delete
$this->size = $size;
[85] Fix | Delete
return true;
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* @param string|int $index
[90] Fix | Delete
* @return bool
[91] Fix | Delete
*/
[92] Fix | Delete
public function offsetExists($index)
[93] Fix | Delete
{
[94] Fix | Delete
return array_key_exists((int) $index, $this->internalArray);
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
/**
[98] Fix | Delete
* @param string|int $index
[99] Fix | Delete
* @return mixed
[100] Fix | Delete
*/
[101] Fix | Delete
public function offsetGet($index)
[102] Fix | Delete
{
[103] Fix | Delete
/** @psalm-suppress MixedReturnStatement */
[104] Fix | Delete
return $this->internalArray[(int) $index];
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* @param string|int $index
[109] Fix | Delete
* @param mixed $newval
[110] Fix | Delete
* @psalm-suppress MixedAssignment
[111] Fix | Delete
*/
[112] Fix | Delete
public function offsetSet($index, $newval)
[113] Fix | Delete
{
[114] Fix | Delete
$this->internalArray[(int) $index] = $newval;
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
/**
[118] Fix | Delete
* @param string|int $index
[119] Fix | Delete
*/
[120] Fix | Delete
public function offsetUnset($index)
[121] Fix | Delete
{
[122] Fix | Delete
unset($this->internalArray[(int) $index]);
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* Rewind iterator back to the start
[127] Fix | Delete
* @link https://php.net/manual/en/splfixedarray.rewind.php
[128] Fix | Delete
* @return void
[129] Fix | Delete
* @since 5.3.0
[130] Fix | Delete
*/
[131] Fix | Delete
public function rewind()
[132] Fix | Delete
{
[133] Fix | Delete
reset($this->internalArray);
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
/**
[137] Fix | Delete
* Return current array entry
[138] Fix | Delete
* @link https://php.net/manual/en/splfixedarray.current.php
[139] Fix | Delete
* @return mixed The current element value.
[140] Fix | Delete
* @since 5.3.0
[141] Fix | Delete
*/
[142] Fix | Delete
public function current()
[143] Fix | Delete
{
[144] Fix | Delete
/** @psalm-suppress MixedReturnStatement */
[145] Fix | Delete
return current($this->internalArray);
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Return current array index
[150] Fix | Delete
* @return int The current array index.
[151] Fix | Delete
*/
[152] Fix | Delete
public function key()
[153] Fix | Delete
{
[154] Fix | Delete
return key($this->internalArray);
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
/**
[158] Fix | Delete
* @return void
[159] Fix | Delete
*/
[160] Fix | Delete
public function next()
[161] Fix | Delete
{
[162] Fix | Delete
next($this->internalArray);
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
/**
[166] Fix | Delete
* Check whether the array contains more elements
[167] Fix | Delete
* @link https://php.net/manual/en/splfixedarray.valid.php
[168] Fix | Delete
* @return bool true if the array contains any more elements, false otherwise.
[169] Fix | Delete
*/
[170] Fix | Delete
public function valid()
[171] Fix | Delete
{
[172] Fix | Delete
if (empty($this->internalArray)) {
[173] Fix | Delete
return false;
[174] Fix | Delete
}
[175] Fix | Delete
$result = next($this->internalArray) !== false;
[176] Fix | Delete
prev($this->internalArray);
[177] Fix | Delete
return $result;
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
/**
[181] Fix | Delete
* Do nothing.
[182] Fix | Delete
*/
[183] Fix | Delete
public function __wakeup()
[184] Fix | Delete
{
[185] Fix | Delete
// NOP
[186] Fix | Delete
}
[187] Fix | Delete
}
[188] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function