Skip to content

Commit 3ba35cb

Browse files
[Mime] Deprecate implementing __sleep/wakeup() on AbstractPart implementations
1 parent eb940c9 commit 3ba35cb

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

AbstractString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ public function wordwrap(int $width = 75, string $break = "\n", bool $cut = fals
708708

709709
public function __serialize(): array
710710
{
711-
if (self::class === (new \ReflectionMethod($this, '__sleep'))->class) {
711+
if (self::class === (new \ReflectionMethod($this, '__sleep'))->class || self::class !== (new \ReflectionMethod($this, '__serialize'))->class) {
712712
return ['string' => $this->string];
713713
}
714714

LazyString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function __toString(): string
103103

104104
public function __serialize(): array
105105
{
106-
if (self::class === (new \ReflectionMethod($this, '__sleep'))->class) {
106+
if (self::class === (new \ReflectionMethod($this, '__sleep'))->class || self::class !== (new \ReflectionMethod($this, '__serialize'))->class) {
107107
$this->__toString();
108108

109109
return ['value' => $this->value];

UnicodeString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public function startsWith(string|iterable|AbstractString $prefix): bool
368368

369369
public function __unserialize(array $data): void
370370
{
371-
if ($wakeup = self::class !== (new \ReflectionMethod($this, '__wakeup'))->class) {
371+
if ($wakeup = self::class !== (new \ReflectionMethod($this, '__wakeup'))->class && self::class === (new \ReflectionMethod($this, '__unserialize'))->class) {
372372
trigger_deprecation('symfony/string', '7.4', 'Implementing "%s::__wakeup()" is deprecated, use "__unserialize()" instead.', get_debug_type($this));
373373
}
374374

0 commit comments

Comments
 (0)