From 79875766dec26539de3544156bd6a14ec14c8eb1 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sat, 23 Mar 2024 18:32:22 +0100 Subject: [PATCH] Simplify test code by using arrow functions --- .../reflection/unittest/InstantiationTest.class.php | 10 +++++----- .../unittest/VirtualPropertiesTest.class.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/php/lang/reflection/unittest/InstantiationTest.class.php b/src/test/php/lang/reflection/unittest/InstantiationTest.class.php index 06c283f..7f85691 100755 --- a/src/test/php/lang/reflection/unittest/InstantiationTest.class.php +++ b/src/test/php/lang/reflection/unittest/InstantiationTest.class.php @@ -11,15 +11,15 @@ class InstantiationTest { /** @return iterable */ private function memberInitializers() { - yield [function($t, $args) { return $t->constructor()->newInstance($args); }]; - yield [function($t, $args) { return $t->initializer('__construct')->newInstance($args); }]; + yield [fn($t, $args) => $t->constructor()->newInstance($args)]; + yield [fn($t, $args) => $t->initializer('__construct')->newInstance($args)]; } /** @return iterable */ private function allInitializers() { - yield [function($t, $args) { return $t->newInstance(...$args); }]; - yield [function($t, $args) { return $t->constructor()->newInstance($args); }]; - yield [function($t, $args) { return $t->initializer('__construct')->newInstance($args); }]; + yield [fn($t, $args) => $t->newInstance(...$args)]; + yield [fn($t, $args) => $t->constructor()->newInstance($args)]; + yield [fn($t, $args) => $t->initializer('__construct')->newInstance($args)]; } #[Test] diff --git a/src/test/php/lang/reflection/unittest/VirtualPropertiesTest.class.php b/src/test/php/lang/reflection/unittest/VirtualPropertiesTest.class.php index ad4d4b9..234c251 100755 --- a/src/test/php/lang/reflection/unittest/VirtualPropertiesTest.class.php +++ b/src/test/php/lang/reflection/unittest/VirtualPropertiesTest.class.php @@ -32,7 +32,7 @@ public function readonly_modifier_shown_in_string_representation($type) { public function virtual_property_included_in_list($type) { Assert::equals( ['fixture' => 'public readonly'], - array_map(function($p) { return $p->modifiers()->names(); }, iterator_to_array($type->properties())) + array_map(fn($p) => $p->modifiers()->names(), iterator_to_array($type->properties())) ); }