mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-20 15:52:24 +02:00
N°5122 - Update libs to new PHP requirements
This commit is contained in:
@@ -1,24 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @see https://github.com/laminas/laminas-stdlib for the canonical source repository
|
||||
* @copyright https://github.com/laminas/laminas-stdlib/blob/master/COPYRIGHT.md
|
||||
* @license https://github.com/laminas/laminas-stdlib/blob/master/LICENSE.md New BSD License
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laminas\Stdlib;
|
||||
|
||||
use ReturnTypeWillChange;
|
||||
use Serializable;
|
||||
use UnexpectedValueException;
|
||||
|
||||
use function is_array;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* Serializable version of SplQueue
|
||||
*
|
||||
* @template TKey of array-key
|
||||
* @template TValue
|
||||
* @extends \SplQueue<TValue>
|
||||
*/
|
||||
class SplQueue extends \SplQueue implements Serializable
|
||||
{
|
||||
/**
|
||||
* Return an array representing the queue
|
||||
*
|
||||
* @return array
|
||||
* @return list<TValue>
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
@@ -34,9 +41,21 @@ class SplQueue extends \SplQueue implements Serializable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function serialize()
|
||||
{
|
||||
return serialize($this->toArray());
|
||||
return serialize($this->__serialize());
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method used for serializing of an instance.
|
||||
*
|
||||
* @return list<TValue>
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function __serialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,9 +64,30 @@ class SplQueue extends \SplQueue implements Serializable
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function unserialize($data)
|
||||
{
|
||||
foreach (unserialize($data) as $item) {
|
||||
$toUnserialize = unserialize($data);
|
||||
if (! is_array($toUnserialize)) {
|
||||
throw new UnexpectedValueException(sprintf(
|
||||
'Cannot deserialize %s instance; corrupt serialization data',
|
||||
self::class
|
||||
));
|
||||
}
|
||||
|
||||
$this->__unserialize($toUnserialize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method used to rebuild an instance.
|
||||
*
|
||||
* @param array<array-key, TValue> $data Data array.
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function __unserialize($data)
|
||||
{
|
||||
foreach ($data as $item) {
|
||||
$this->push($item);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user