@@ -165,6 +165,68 @@ public function testReflectionParameterScalar()
165165 );
166166 }
167167
168+ /**
169+ * @requires PHP 8
170+ */
171+ public function testReflectionParameterMixed ()
172+ {
173+ $ f = eval ('return function (mixed $a) {}; ' );
174+ $ var = new \ReflectionParameter ($ f , 0 );
175+
176+ $ this ->assertDumpMatchesFormat (
177+ <<<'EOTXT'
178+ ReflectionParameter {
179+ +name: "a"
180+ position: 0
181+ allowsNull: true
182+ typeHint: "mixed"
183+ }
184+ EOTXT
185+ , $ var
186+ );
187+ }
188+
189+ /**
190+ * @requires PHP 8
191+ */
192+ public function testReflectionParameterUnion ()
193+ {
194+ $ f = eval ('return function (int|float $a) {}; ' );
195+ $ var = new \ReflectionParameter ($ f , 0 );
196+
197+ $ this ->assertDumpMatchesFormat (
198+ <<<'EOTXT'
199+ ReflectionParameter {
200+ +name: "a"
201+ position: 0
202+ typeHint: "int|float"
203+ }
204+ EOTXT
205+ , $ var
206+ );
207+ }
208+
209+ /**
210+ * @requires PHP 8
211+ */
212+ public function testReflectionParameterNullableUnion ()
213+ {
214+ $ f = eval ('return function (int|float|null $a) {}; ' );
215+ $ var = new \ReflectionParameter ($ f , 0 );
216+
217+ $ this ->assertDumpMatchesFormat (
218+ <<<'EOTXT'
219+ ReflectionParameter {
220+ +name: "a"
221+ position: 0
222+ allowsNull: true
223+ typeHint: "int|float|null"
224+ }
225+ EOTXT
226+ , $ var
227+ );
228+ }
229+
168230 public function testReturnType ()
169231 {
170232 $ f = eval ('return function ():int {}; ' );
@@ -184,6 +246,72 @@ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
184246 );
185247 }
186248
249+ /**
250+ * @requires PHP 8
251+ */
252+ public function testMixedReturnType ()
253+ {
254+ $ f = eval ('return function (): mixed {}; ' );
255+ $ line = __LINE__ - 1 ;
256+
257+ $ this ->assertDumpMatchesFormat (
258+ <<<EOTXT
259+ Closure(): mixed {
260+ returnType: "mixed"
261+ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
262+ this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
263+ file: "%sReflectionCasterTest.php( $ line) : eval()'d code"
264+ line: "1 to 1"
265+ }
266+ EOTXT
267+ , $ f
268+ );
269+ }
270+
271+ /**
272+ * @requires PHP 8
273+ */
274+ public function testUnionReturnType ()
275+ {
276+ $ f = eval ('return function (): int|float {}; ' );
277+ $ line = __LINE__ - 1 ;
278+
279+ $ this ->assertDumpMatchesFormat (
280+ <<<EOTXT
281+ Closure(): int|float {
282+ returnType: "int|float"
283+ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
284+ this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
285+ file: "%sReflectionCasterTest.php( $ line) : eval()'d code"
286+ line: "1 to 1"
287+ }
288+ EOTXT
289+ , $ f
290+ );
291+ }
292+
293+ /**
294+ * @requires PHP 8
295+ */
296+ public function testNullableUnionReturnType ()
297+ {
298+ $ f = eval ('return function (): int|float|null {}; ' );
299+ $ line = __LINE__ - 1 ;
300+
301+ $ this ->assertDumpMatchesFormat (
302+ <<<EOTXT
303+ Closure(): int|float|null {
304+ returnType: "int|float|null"
305+ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
306+ this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
307+ file: "%sReflectionCasterTest.php( $ line) : eval()'d code"
308+ line: "1 to 1"
309+ }
310+ EOTXT
311+ , $ f
312+ );
313+ }
314+
187315 public function testGenerator ()
188316 {
189317 if (\extension_loaded ('xdebug ' )) {
0 commit comments