[String] implement __sleep()/__wakeup() on strings

This commit is contained in:
Nicolas Grekas 2019-12-04 09:11:16 +01:00
parent 98694d8677
commit 416e40d943
2 changed files with 10 additions and 0 deletions

View File

@ -692,6 +692,11 @@ abstract class AbstractString implements \JsonSerializable
return $str;
}
public function __sleep(): array
{
return ['string'];
}
public function __clone()
{
$this->ignoreCase = false;

View File

@ -347,6 +347,11 @@ class UnicodeString extends AbstractUnicodeString
return $prefix === grapheme_extract($this->string, \strlen($prefix), GRAPHEME_EXTR_MAXBYTES);
}
public function __wakeup()
{
normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string);
}
public function __clone()
{
if (null === $this->ignoreCase) {