Skip to content

Commit

Permalink
Simplify test code by using arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Mar 23, 2024
1 parent 9cf6410 commit 7987576
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
);
}

Expand Down

0 comments on commit 7987576

Please sign in to comment.