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