compat avec les nur/sery
This commit is contained in:
parent
fd27e2ee37
commit
756502361f
|
@ -309,8 +309,27 @@ class Stream extends AbstractIterator implements IReader, IWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var bool faut-il faire un mapping pour la compatibilité avec nur/sery */
|
||||||
|
const UNSERIALIZE_NURSERY_COMPAT = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string[] mappings pour la compatibilité avec des fichiers générés par
|
||||||
|
* nur/sery
|
||||||
|
*/
|
||||||
|
const UNSERIALIZE_NURSERY_MAPPING = [
|
||||||
|
'O:22:"nur\sery\php\time\Date":' => 'O:19:"nulib\php\time\Date":',
|
||||||
|
'O:26:"nur\sery\php\time\DateTime":' => 'O:23:"nulib\php\time\DateTime":',
|
||||||
|
'O:23:"nur\sery\php\time\Delay":' => 'O:20:"nulib\php\time\Delay":',
|
||||||
|
];
|
||||||
|
|
||||||
function unserialize(?array $options=null, bool $close=true, bool $alreadyLocked=false) {
|
function unserialize(?array $options=null, bool $close=true, bool $alreadyLocked=false) {
|
||||||
$args = [$this->getContents($close, $alreadyLocked)];
|
$contents = $this->getContents($close, $alreadyLocked);
|
||||||
|
if (static::UNSERIALIZE_NURSERY_COMPAT) {
|
||||||
|
foreach (self::UNSERIALIZE_NURSERY_MAPPING as $from => $to) {
|
||||||
|
$contents = str_replace($from, $to, $contents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$args = [$contents];
|
||||||
if ($options !== null) $args[] = $options;
|
if ($options !== null) $args[] = $options;
|
||||||
return unserialize(...$args);
|
return unserialize(...$args);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue