Skip to content

Commit e7e3701

Browse files
More cleanups related to internal sleep/wakeup usages
1 parent e362338 commit e7e3701

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function __serialize(): array
143143
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
144144
}
145145

146-
public function __wakeup(): void
146+
public function __unserialize(array $data): void
147147
{
148148
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
149149
}

src/Symfony/Component/HttpClient/Response/AmpResponseV5.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ public function getInfo(?string $type = null): mixed
122122
return null !== $type ? $this->info[$type] ?? null : $this->info;
123123
}
124124

125-
public function __sleep(): array
125+
public function __serialize(): array
126126
{
127127
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
128128
}
129129

130-
public function __wakeup(): void
130+
public function __unserialize(array $data): void
131131
{
132132
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
133133
}

src/Symfony/Component/Validator/Constraint.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,22 @@ public function getTargets(): string|array
313313
*
314314
* @internal
315315
*/
316-
public function __sleep(): array
316+
public function __serialize(): array
317317
{
318318
// Initialize "groups" option if it is not set
319319
$this->groups;
320320

321-
return array_keys(get_object_vars($this));
321+
$data = [];
322+
$class = $this::class;
323+
foreach ((array) $this as $k => $v) {
324+
$data[match (true) {
325+
'' === $k || "\0" !== $k[0] => $k,
326+
str_starts_with($k, "\0*\0") => substr($k, 3),
327+
str_starts_with($k, "\0{$class}\0") => substr($k, 2 + \strlen($class)),
328+
default => $k,
329+
}] = $v;
330+
}
331+
332+
return $data;
322333
}
323334
}

0 commit comments

Comments
 (0)