bug #34801 [String] implement __sleep()/__wakeup() on strings (nicolas-grekas)

This PR was merged into the 5.0 branch.

Discussion
----------

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

| Q             | A
| ------------- | ---
| Branch?       | 5.0
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This resets the transient ignoreCase state on unserialized instances.

Commits
-------

416e40d943 [String] implement __sleep()/__wakeup() on strings
This commit is contained in:
Fabien Potencier 2019-12-07 14:35:22 +01:00
commit ed3e111e1d
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) {