Skip to content

Commit 4b88704

Browse files
Upgrade/Install: Update sodium_compat to v1.21.2.
Version 1.21.2 is mostly to prevent deprecation warnings on PHP 8.5. These should never be encountered in practice (as the only file in scope was an `SplFixedArray` polyfill for PHP 5.2, which should never be executed on PHP 8.5), but for completeness the polyfill was updated. References: * [https://github.com/paragonie/sodium_compat/releases/tag/v1.21.2 sodium_compat 1.21.2 release notes] * [paragonie/sodium_compat@v1.20.1...v1.21.2 Full list of changes in sodium_compat 1.21.2] Follow-up to [55699], [58752], [58753]. Props paragoninitiativeenterprises, jrf, johnbillion, TobiasBg, SergeyBiryukov. Fixes #64008. git-svn-id: https://develop.svn.wordpress.org/trunk@60787 602fd350-edb4-49c9-b593-d223f7449a82
1 parent e1fe605 commit 4b88704

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/wp-includes/sodium_compat/src/PHP52/SplFixedArray.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function __construct($size = 0)
3232
/**
3333
* @return int
3434
*/
35+
#[\ReturnTypeWillChange]
3536
public function count()
3637
{
3738
return count($this->internalArray);
@@ -72,6 +73,7 @@ public static function fromArray(array $array, $save_indexes = true)
7273
/**
7374
* @return int
7475
*/
76+
#[\ReturnTypeWillChange]
7577
public function getSize()
7678
{
7779
return $this->size;
@@ -81,6 +83,7 @@ public function getSize()
8183
* @param int $size
8284
* @return bool
8385
*/
86+
#[\ReturnTypeWillChange]
8487
public function setSize($size)
8588
{
8689
$this->size = $size;
@@ -91,6 +94,7 @@ public function setSize($size)
9194
* @param string|int $index
9295
* @return bool
9396
*/
97+
#[\ReturnTypeWillChange]
9498
public function offsetExists($index)
9599
{
96100
return array_key_exists((int) $index, $this->internalArray);
@@ -100,6 +104,7 @@ public function offsetExists($index)
100104
* @param string|int $index
101105
* @return mixed
102106
*/
107+
#[\ReturnTypeWillChange]
103108
public function offsetGet($index)
104109
{
105110
/** @psalm-suppress MixedReturnStatement */
@@ -111,6 +116,7 @@ public function offsetGet($index)
111116
* @param mixed $newval
112117
* @psalm-suppress MixedAssignment
113118
*/
119+
#[\ReturnTypeWillChange]
114120
public function offsetSet($index, $newval)
115121
{
116122
$this->internalArray[(int) $index] = $newval;
@@ -119,6 +125,7 @@ public function offsetSet($index, $newval)
119125
/**
120126
* @param string|int $index
121127
*/
128+
#[\ReturnTypeWillChange]
122129
public function offsetUnset($index)
123130
{
124131
unset($this->internalArray[(int) $index]);
@@ -130,6 +137,7 @@ public function offsetUnset($index)
130137
* @return void
131138
* @since 5.3.0
132139
*/
140+
#[\ReturnTypeWillChange]
133141
public function rewind()
134142
{
135143
reset($this->internalArray);
@@ -141,6 +149,7 @@ public function rewind()
141149
* @return mixed The current element value.
142150
* @since 5.3.0
143151
*/
152+
#[\ReturnTypeWillChange]
144153
public function current()
145154
{
146155
/** @psalm-suppress MixedReturnStatement */
@@ -151,6 +160,7 @@ public function current()
151160
* Return current array index
152161
* @return int The current array index.
153162
*/
163+
#[\ReturnTypeWillChange]
154164
public function key()
155165
{
156166
return key($this->internalArray);
@@ -159,6 +169,7 @@ public function key()
159169
/**
160170
* @return void
161171
*/
172+
#[\ReturnTypeWillChange]
162173
public function next()
163174
{
164175
next($this->internalArray);
@@ -169,6 +180,7 @@ public function next()
169180
* @link https://php.net/manual/en/splfixedarray.valid.php
170181
* @return bool true if the array contains any more elements, false otherwise.
171182
*/
183+
#[\ReturnTypeWillChange]
172184
public function valid()
173185
{
174186
if (empty($this->internalArray)) {
@@ -179,11 +191,31 @@ public function valid()
179191
return $result;
180192
}
181193

194+
public function __sleep()
195+
{
196+
return $this->internalArray;
197+
}
198+
182199
/**
183200
* Do nothing.
184201
*/
185202
public function __wakeup()
186203
{
187204
// NOP
188205
}
189-
}
206+
207+
public function __serialize()
208+
{
209+
return array_values($this->internalArray);
210+
}
211+
212+
public function __unserialize(array $data)
213+
{
214+
$length = count($data);
215+
$values = array_values($data);
216+
for ($i = 0; $i < $length; ++$i) {
217+
$this->internalArray[$i] = $values[$i];
218+
}
219+
$this->size = $length;
220+
}
221+
}

0 commit comments

Comments
 (0)