@@ -27,98 +27,98 @@ class LegacyProxyHelperTest extends ProxyHelperTest
2727 public function testGenerateLazyProxy ()
2828 {
2929 $ expected = <<<'EOPHP'
30- extends \Symfony\Component\VarExporter\Tests\TestForProxyHelper implements \Symfony\Component\VarExporter\LazyObjectInterface
31- {
32- use \Symfony\Component\VarExporter\LazyProxyTrait;
33-
34- private const LAZY_OBJECT_PROPERTY_SCOPES = [];
35-
36- public function foo1(): ?\Symfony\Component\VarExporter\Tests\Bar
30+ extends \Symfony\Component\VarExporter\Tests\TestForProxyHelper implements \Symfony\Component\VarExporter\LazyObjectInterface
3731 {
38- if (isset($this->lazyObjectState)) {
39- return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo1(...\func_get_args());
40- }
32+ use \Symfony\Component\VarExporter\LazyProxyTrait;
4133
42- return parent::foo1(...\func_get_args());
43- }
34+ private const LAZY_OBJECT_PROPERTY_SCOPES = [];
4435
45- public function foo4(\Symfony\Component\VarExporter\Tests\Bar|string $b, &$d): void
46- {
47- if (isset($this->lazyObjectState)) {
48- ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo4($b, $d, ...\array_slice(\func_get_args(), 2));
49- } else {
50- parent::foo4($b, $d, ...\array_slice(\func_get_args(), 2));
36+ public function foo1(): ?\Symfony\Component\VarExporter\Tests\Bar
37+ {
38+ if (isset($this->lazyObjectState)) {
39+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo1(...\func_get_args());
40+ }
41+
42+ return parent::foo1(...\func_get_args());
5143 }
52- }
5344
54- protected function foo7()
55- {
56- if (isset($this->lazyObjectState)) {
57- return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo7(...\func_get_args());
45+ public function foo4(\Symfony\Component\VarExporter\Tests\Bar|string $b, &$d): void
46+ {
47+ if (isset($this->lazyObjectState)) {
48+ ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo4($b, $d, ...\array_slice(\func_get_args(), 2));
49+ } else {
50+ parent::foo4($b, $d, ...\array_slice(\func_get_args(), 2));
51+ }
5852 }
5953
60- return throw new \BadMethodCallException('Cannot forward abstract method "Symfony\Component\VarExporter\Tests\TestForProxyHelper::foo7()".');
54+ protected function foo7()
55+ {
56+ if (isset($this->lazyObjectState)) {
57+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo7(...\func_get_args());
58+ }
59+
60+ return throw new \BadMethodCallException('Cannot forward abstract method "Symfony\Component\VarExporter\Tests\TestForProxyHelper::foo7()".');
61+ }
6162 }
62- }
6363
64- // Help opcache.preload discover always-needed symbols
65- class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class);
66- class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
67- class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
64+ // Help opcache.preload discover always-needed symbols
65+ class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class);
66+ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
67+ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
6868
69- EOPHP;
69+ EOPHP;
7070
7171 $ this ->assertSame ($ expected , ProxyHelper::generateLazyProxy (new \ReflectionClass (TestForProxyHelper::class)));
7272 }
7373
7474 public function testGenerateLazyProxyForInterfaces ()
7575 {
7676 $ expected = <<<'EOPHP'
77- implements \Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface1, \Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2, \Symfony\Component\VarExporter\LazyObjectInterface
78- {
79- use \Symfony\Component\VarExporter\LazyProxyTrait;
77+ implements \Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface1, \Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2, \Symfony\Component\VarExporter\LazyObjectInterface
78+ {
79+ use \Symfony\Component\VarExporter\LazyProxyTrait;
8080
81- private const LAZY_OBJECT_PROPERTY_SCOPES = [];
81+ private const LAZY_OBJECT_PROPERTY_SCOPES = [];
8282
83- public function initializeLazyObject(): \Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface1&\Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2
84- {
85- if ($state = $this->lazyObjectState ?? null) {
86- return $state->realInstance ??= ($state->initializer)();
83+ public function initializeLazyObject(): \Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface1&\Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2
84+ {
85+ if ($state = $this->lazyObjectState ?? null) {
86+ return $state->realInstance ??= ($state->initializer)();
87+ }
88+
89+ return $this;
8790 }
8891
89- return $this;
90- }
92+ public function foo1(): ?\Symfony\Component\VarExporter\Tests\Bar
93+ {
94+ if (isset($this->lazyObjectState)) {
95+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo1(...\func_get_args());
96+ }
9197
92- public function foo1(): ?\Symfony\Component\VarExporter\Tests\Bar
93- {
94- if (isset($this->lazyObjectState)) {
95- return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo1(...\func_get_args());
98+ return throw new \BadMethodCallException('Cannot forward abstract method "Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface1::foo1()".');
9699 }
97100
98- return throw new \BadMethodCallException('Cannot forward abstract method "Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface1::foo1()".');
99- }
101+ public function foo2(?\Symfony\Component\VarExporter\Tests\Bar $b, ...$d): \Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2
102+ {
103+ if (isset($this->lazyObjectState)) {
104+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo2(...\func_get_args());
105+ }
100106
101- public function foo2(?\Symfony\Component\VarExporter\Tests\Bar $b, ...$d): \Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2
102- {
103- if (isset($this->lazyObjectState)) {
104- return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo2(...\func_get_args());
107+ return throw new \BadMethodCallException('Cannot forward abstract method "Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2::foo2()".');
105108 }
106109
107- return throw new \BadMethodCallException('Cannot forward abstract method "Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2::foo2()".');
108- }
109-
110- public static function foo3(): string
111- {
112- throw new \BadMethodCallException('Cannot forward abstract method "Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2::foo3()".');
110+ public static function foo3(): string
111+ {
112+ throw new \BadMethodCallException('Cannot forward abstract method "Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2::foo3()".');
113+ }
113114 }
114- }
115115
116- // Help opcache.preload discover always-needed symbols
117- class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class);
118- class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
119- class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
116+ // Help opcache.preload discover always-needed symbols
117+ class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class);
118+ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class);
119+ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class);
120120
121- EOPHP;
121+ EOPHP;
122122
123123 $ this ->assertSame ($ expected , ProxyHelper::generateLazyProxy (null , [new \ReflectionClass (TestForProxyHelperInterface1::class), new \ReflectionClass (TestForProxyHelperInterface2::class)]));
124124 }
@@ -130,50 +130,50 @@ public function __unserialize($array): void
130130 {
131131 }
132132 }, <<<'EOPHP'
133- implements \Symfony\Component\VarExporter\LazyObjectInterface
134- {
135- use \Symfony\Component\VarExporter\LazyProxyTrait {
136- __unserialize as private __doUnserialize;
137- }
133+ implements \Symfony\Component\VarExporter\LazyObjectInterface
134+ {
135+ use \Symfony\Component\VarExporter\LazyProxyTrait {
136+ __unserialize as private __doUnserialize;
137+ }
138138
139- private const LAZY_OBJECT_PROPERTY_SCOPES = [];
139+ private const LAZY_OBJECT_PROPERTY_SCOPES = [];
140140
141- public function __unserialize($data): void
142- {
143- $this->__doUnserialize($data);
141+ public function __unserialize($data): void
142+ {
143+ $this->__doUnserialize($data);
144+ }
144145 }
145- }
146- EOPHP];
146+ EOPHP];
147147
148148 yield 'type hinted __unserialize method' => [new class {
149149 public function __unserialize(array $array): void
150150 {
151151 }
152152 }, <<<'EOPHP'
153- implements \Symfony\Component\VarExporter\LazyObjectInterface
154- {
155- use \Symfony\Component\VarExporter\LazyProxyTrait;
153+ implements \Symfony\Component\VarExporter\LazyObjectInterface
154+ {
155+ use \Symfony\Component\VarExporter\LazyProxyTrait;
156156
157- private const LAZY_OBJECT_PROPERTY_SCOPES = [];
158- }
159- EOPHP];
157+ private const LAZY_OBJECT_PROPERTY_SCOPES = [];
158+ }
159+ EOPHP];
160160 }
161161
162162 public function testAttributes()
163163 {
164164 $expected = <<<'EOPHP'
165165
166- public function foo(#[\SensitiveParameter] $a): int
167- {
168- if (isset($this->lazyObjectState)) {
169- return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo(...\func_get_args());
170- }
166+ public function foo(#[\SensitiveParameter] $a): int
167+ {
168+ if (isset($this->lazyObjectState)) {
169+ return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->foo(...\func_get_args());
170+ }
171171
172- return parent::foo(...\func_get_args());
172+ return parent::foo(...\func_get_args());
173+ }
173174 }
174- }
175175
176- EOPHP;
176+ EOPHP;
177177
178178 $ class = new \ReflectionClass (new class {
179179 #[SomeAttribute]
0 commit comments