Skip to content

Commit 0f62950

Browse files
committed
[VarExporter] LazyProxyTrait::__unserialize() should not be typehinted
1 parent e3b80f3 commit 0f62950

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/Symfony/Component/VarExporter/LazyProxyTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public function __serialize(): array
309309
return $data;
310310
}
311311

312-
public function __unserialize(array $data): void
312+
public function __unserialize($data): void
313313
{
314314
$class = self::class;
315315

src/Symfony/Component/VarExporter/Tests/LazyProxyTraitTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,30 @@ public function testNormalization()
298298
$this->assertSame(['property' => 'property', 'method' => 'method'], $output);
299299
}
300300

301+
/**
302+
* @dataProvider classWithUnserializeMagicMethodProvider
303+
*/
304+
public function testItCanProxifyClassWithUnserializeMagicMethod(object $obj)
305+
{
306+
$proxy = $this->createLazyProxy($obj::class, fn () => $obj);
307+
self::assertIsObject($proxy);
308+
}
309+
310+
public static function classWithUnserializeMagicMethodProvider(): iterable
311+
{
312+
yield 'not type hinted __unserialize method' => [new class() {
313+
public function __unserialize($array)
314+
{
315+
}
316+
}];
317+
318+
yield 'type hinted __unserialize method' => [new class() {
319+
public function __unserialize(array $array)
320+
{
321+
}
322+
}];
323+
}
324+
301325
/**
302326
* @template T
303327
*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy