@@ -153,7 +153,7 @@ public function testReflectionParameter()
153153
154154 public function testReflectionParameterScalar ()
155155 {
156- $ f = eval ( ' return function (int $a) {}; ' ) ;
156+ $ f = function (int $ a ) {};
157157 $ var = new \ReflectionParameter ($ f , 0 );
158158
159159 $ this ->assertDumpMatchesFormat (
@@ -170,7 +170,7 @@ public function testReflectionParameterScalar()
170170
171171 public function testReflectionParameterMixed ()
172172 {
173- $ f = eval ( ' return function (mixed $a) {}; ' ) ;
173+ $ f = function (mixed $ a ) {};
174174 $ var = new \ReflectionParameter ($ f , 0 );
175175
176176 $ this ->assertDumpMatchesFormat (
@@ -188,7 +188,7 @@ public function testReflectionParameterMixed()
188188
189189 public function testReflectionParameterUnion ()
190190 {
191- $ f = eval ( ' return function (int|float $a) {}; ' ) ;
191+ $ f = function (int |float $ a ) {};
192192 $ var = new \ReflectionParameter ($ f , 0 );
193193
194194 $ this ->assertDumpMatchesFormat (
@@ -205,7 +205,7 @@ public function testReflectionParameterUnion()
205205
206206 public function testReflectionParameterNullableUnion ()
207207 {
208- $ f = eval ( ' return function (int|float|null $a) {}; ' ) ;
208+ $ f = function (int |float |null $ a ) {};
209209 $ var = new \ReflectionParameter ($ f , 0 );
210210
211211 $ this ->assertDumpMatchesFormat (
@@ -221,12 +221,9 @@ public function testReflectionParameterNullableUnion()
221221 );
222222 }
223223
224- /**
225- * @requires PHP 8.1
226- */
227224 public function testReflectionParameterIntersection ()
228225 {
229- $ f = eval ( ' return function (Traversable&Countable $a) {}; ' ) ;
226+ $ f = function (\ Traversable &\ Countable $ a ) {};
230227 $ var = new \ReflectionParameter ($ f , 0 );
231228
232229 $ this ->assertDumpMatchesFormat (
@@ -296,9 +293,6 @@ public function testReflectionUnionType()
296293 );
297294 }
298295
299- /**
300- * @requires PHP 8.1
301- */
302296 public function testReflectionIntersectionType ()
303297 {
304298 $ var = (new \ReflectionProperty (ReflectionIntersectionTypeFixture::class, 'a ' ))->getType ();
@@ -339,17 +333,16 @@ public function testExtendsReflectionType()
339333
340334 public function testReturnType ()
341335 {
342- $ f = eval ('return function ():int {}; ' );
343- $ line = __LINE__ - 1 ;
336+ $ f = function ():int {};
344337
345338 $ this ->assertDumpMatchesFormat (
346339 <<<EOTXT
347340Closure(): int {
348341 returnType: "int"
349342 class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
350343 this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
351- file: "%sReflectionCasterTest.php( $ line ) : eval()'d code "
352- line: "1 to 1 "
344+ file: "%s "
345+ line: "%s "
353346}
354347EOTXT
355348 , $ f
@@ -358,17 +351,16 @@ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
358351
359352 public function testMixedReturnType ()
360353 {
361- $ f = eval ('return function (): mixed {}; ' );
362- $ line = __LINE__ - 1 ;
354+ $ f = function (): mixed {};
363355
364356 $ this ->assertDumpMatchesFormat (
365357 <<<EOTXT
366358Closure(): mixed {
367359 returnType: "mixed"
368360 class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
369361 this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
370- file: "%sReflectionCasterTest.php( $ line ) : eval()'d code "
371- line: "1 to 1 "
362+ file: "%s "
363+ line: "%s "
372364}
373365EOTXT
374366 , $ f
@@ -377,17 +369,16 @@ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
377369
378370 public function testUnionReturnType ()
379371 {
380- $ f = eval ('return function (): int|float {}; ' );
381- $ line = __LINE__ - 1 ;
372+ $ f = function (): int |float {};
382373
383374 $ this ->assertDumpMatchesFormat (
384375 <<<EOTXT
385376Closure(): int|float {
386377 returnType: "int|float"
387378 class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
388379 this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
389- file: "%sReflectionCasterTest.php( $ line ) : eval()'d code "
390- line: "1 to 1 "
380+ file: "%s "
381+ line: "%s "
391382}
392383EOTXT
393384 , $ f
@@ -396,17 +387,16 @@ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
396387
397388 public function testNullableUnionReturnType ()
398389 {
399- $ f = eval ('return function (): int|float|null {}; ' );
400- $ line = __LINE__ - 1 ;
390+ $ f = function (): int |float |null {};
401391
402392 $ this ->assertDumpMatchesFormat (
403393 <<<EOTXT
404394Closure(): int|float|null {
405395 returnType: "int|float|null"
406396 class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
407397 this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
408- file: "%sReflectionCasterTest.php( $ line ) : eval()'d code "
409- line: "1 to 1 "
398+ file: "%s "
399+ line: "%s "
410400}
411401EOTXT
412402 , $ f
@@ -485,21 +475,17 @@ public function testGenerator()
485475 $ this ->assertDumpMatchesFormat ($ expectedDump , $ generator );
486476 }
487477
488- /**
489- * @requires PHP 8.1
490- */
491478 public function testNewInInitializer ()
492479 {
493- $ f = eval ('return function ($a = new stdClass()) {}; ' );
494- $ line = __LINE__ - 1 ;
480+ $ f = function ($ a = new \stdClass ()) {};
495481
496482 $ this ->assertDumpMatchesFormat (
497483 <<<EOTXT
498484Closure( \$a = new stdClass) {
499485 class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
500486 this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
501- file: "%sReflectionCasterTest.php( $ line ) : eval()'d code "
502- line: "1 to 1 "
487+ file: "%s "
488+ line: "%s "
503489}
504490EOTXT
505491 , $ f
0 commit comments