From 416e40d943b4e8330f6980ef28263a6b62f76ff3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 4 Dec 2019 09:11:16 +0100 Subject: [PATCH] [String] implement __sleep()/__wakeup() on strings --- src/Symfony/Component/String/AbstractString.php | 5 +++++ src/Symfony/Component/String/UnicodeString.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/Symfony/Component/String/AbstractString.php b/src/Symfony/Component/String/AbstractString.php index 435363b798d25..e56697e391549 100644 --- a/src/Symfony/Component/String/AbstractString.php +++ b/src/Symfony/Component/String/AbstractString.php @@ -692,6 +692,11 @@ public function wordwrap(int $width = 75, string $break = "\n", bool $cut = fals return $str; } + public function __sleep(): array + { + return ['string']; + } + public function __clone() { $this->ignoreCase = false; diff --git a/src/Symfony/Component/String/UnicodeString.php b/src/Symfony/Component/String/UnicodeString.php index 61e8c008dcb35..d7df6f5e1400b 100644 --- a/src/Symfony/Component/String/UnicodeString.php +++ b/src/Symfony/Component/String/UnicodeString.php @@ -347,6 +347,11 @@ public function startsWith($prefix): bool 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) {