Skip to content

Commit 7caeebb

Browse files
Merge branch '7.3' into 7.4
* 7.3: Replace __sleep/wakeup() by __(un)serialize() for throwing and internal usages [TypeInfo] simplify identifier comparison in isIdentifiedBy method
2 parents ece5f0d + 9163704 commit 7caeebb

File tree

1 file changed

+2
-65
lines changed

1 file changed

+2
-65
lines changed

Part/MessagePart.php

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -59,75 +59,12 @@ public function bodyToIterable(): iterable
5959

6060
public function __serialize(): array
6161
{
62-
if (self::class === (new \ReflectionMethod($this, '__sleep'))->class || self::class !== (new \ReflectionMethod($this, '__serialize'))->class) {
63-
return ['message' => $this->message];
64-
}
65-
66-
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__sleep()" is deprecated, use "__serialize()" instead.', get_debug_type($this));
67-
68-
$data = [];
69-
foreach ($this->__sleep() as $key) {
70-
try {
71-
if (($r = new \ReflectionProperty($this, $key))->isInitialized($this)) {
72-
$data[$key] = $r->getValue($this);
73-
}
74-
} catch (\ReflectionException) {
75-
$data[$key] = $this->$key;
76-
}
77-
}
78-
79-
return $data;
62+
return ['message' => $this->message];
8063
}
8164

8265
public function __unserialize(array $data): void
8366
{
84-
if ($wakeup = self::class !== (new \ReflectionMethod($this, '__wakeup'))->class && self::class === (new \ReflectionMethod($this, '__unserialize'))->class) {
85-
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__wakeup()" is deprecated, use "__unserialize()" instead.', get_debug_type($this));
86-
}
87-
88-
if (\in_array(array_keys($data), [['message'], ["\0".self::class."\0message"]], true)) {
89-
$this->message = $data['message'] ?? $data["\0".self::class."\0message"];
90-
91-
if ($wakeup) {
92-
$this->__wakeup();
93-
} else {
94-
$this->__construct($this->message);
95-
}
96-
97-
return;
98-
}
99-
100-
trigger_deprecation('symfony/mime', '7.4', 'Passing more than just key "message" to "%s::__unserialize()" is deprecated, populate properties in "%s::__unserialize()" instead.', self::class, get_debug_type($this));
101-
102-
\Closure::bind(function ($data) use ($wakeup) {
103-
foreach ($data as $key => $value) {
104-
$this->{("\0" === $key[0] ?? '') ? substr($key, 1 + strrpos($key, "\0")) : $key} = $value;
105-
}
106-
107-
if ($wakeup) {
108-
$this->__wakeup();
109-
} else {
110-
$this->__construct($this->message);
111-
}
112-
}, $this, static::class)($data);
113-
}
114-
115-
/**
116-
* @deprecated since Symfony 7.4, will be replaced by `__unserialize()` in 8.0
117-
*/
118-
public function __sleep(): array
119-
{
120-
trigger_deprecation('symfony/mime', '7.4', 'Calling "%s::__sleep()" is deprecated, use "__serialize()" instead.', get_debug_type($this));
121-
122-
return ['message'];
123-
}
124-
125-
/**
126-
* @deprecated since Symfony 7.4, will be replaced by `__unserialize()` in 8.0
127-
*/
128-
public function __wakeup(): void
129-
{
130-
trigger_deprecation('symfony/mime', '7.4', 'Calling "%s::__wakeup()" is deprecated, use "__unserialize()" instead.', get_debug_type($this));
67+
$this->message = $data['message'] ?? $data["\0".self::class."\0message"];
13168

13269
$this->__construct($this->message);
13370
}

0 commit comments

Comments
 (0)