@@ -149,6 +149,68 @@ public function testReflectionParameterScalar()
149149 );
150150 }
151151
152+ /**
153+ * @requires PHP 8
154+ */
155+ public function testReflectionParameterMixed ()
156+ {
157+ $ f = eval ('return function (mixed $a) {}; ' );
158+ $ var = new \ReflectionParameter ($ f , 0 );
159+
160+ $ this ->assertDumpMatchesFormat (
161+ <<<'EOTXT'
162+ ReflectionParameter {
163+ +name: "a"
164+ position: 0
165+ allowsNull: true
166+ typeHint: "mixed"
167+ }
168+ EOTXT
169+ , $ var
170+ );
171+ }
172+
173+ /**
174+ * @requires PHP 8
175+ */
176+ public function testReflectionParameterUnion ()
177+ {
178+ $ f = eval ('return function (int|float $a) {}; ' );
179+ $ var = new \ReflectionParameter ($ f , 0 );
180+
181+ $ this ->assertDumpMatchesFormat (
182+ <<<'EOTXT'
183+ ReflectionParameter {
184+ +name: "a"
185+ position: 0
186+ typeHint: "int|float"
187+ }
188+ EOTXT
189+ , $ var
190+ );
191+ }
192+
193+ /**
194+ * @requires PHP 8
195+ */
196+ public function testReflectionParameterNullableUnion ()
197+ {
198+ $ f = eval ('return function (int|float|null $a) {}; ' );
199+ $ var = new \ReflectionParameter ($ f , 0 );
200+
201+ $ this ->assertDumpMatchesFormat (
202+ <<<'EOTXT'
203+ ReflectionParameter {
204+ +name: "a"
205+ position: 0
206+ allowsNull: true
207+ typeHint: "int|float|null"
208+ }
209+ EOTXT
210+ , $ var
211+ );
212+ }
213+
152214 public function testReturnType ()
153215 {
154216 $ f = eval ('return function ():int {}; ' );
@@ -168,6 +230,72 @@ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
168230 );
169231 }
170232
233+ /**
234+ * @requires PHP 8
235+ */
236+ public function testMixedReturnType ()
237+ {
238+ $ f = eval ('return function (): mixed {}; ' );
239+ $ line = __LINE__ - 1 ;
240+
241+ $ this ->assertDumpMatchesFormat (
242+ <<<EOTXT
243+ Closure(): mixed {
244+ returnType: "mixed"
245+ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
246+ this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
247+ file: "%sReflectionCasterTest.php( $ line) : eval()'d code"
248+ line: "1 to 1"
249+ }
250+ EOTXT
251+ , $ f
252+ );
253+ }
254+
255+ /**
256+ * @requires PHP 8
257+ */
258+ public function testUnionReturnType ()
259+ {
260+ $ f = eval ('return function (): int|float {}; ' );
261+ $ line = __LINE__ - 1 ;
262+
263+ $ this ->assertDumpMatchesFormat (
264+ <<<EOTXT
265+ Closure(): int|float {
266+ returnType: "int|float"
267+ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
268+ this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
269+ file: "%sReflectionCasterTest.php( $ line) : eval()'d code"
270+ line: "1 to 1"
271+ }
272+ EOTXT
273+ , $ f
274+ );
275+ }
276+
277+ /**
278+ * @requires PHP 8
279+ */
280+ public function testNullableUnionReturnType ()
281+ {
282+ $ f = eval ('return function (): int|float|null {}; ' );
283+ $ line = __LINE__ - 1 ;
284+
285+ $ this ->assertDumpMatchesFormat (
286+ <<<EOTXT
287+ Closure(): int|float|null {
288+ returnType: "int|float|null"
289+ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
290+ this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
291+ file: "%sReflectionCasterTest.php( $ line) : eval()'d code"
292+ line: "1 to 1"
293+ }
294+ EOTXT
295+ , $ f
296+ );
297+ }
298+
171299 public function testGenerator ()
172300 {
173301 if (\extension_loaded ('xdebug ' )) {
0 commit comments