From 606e81ff061d38dc0f222685e1260cbe03fdd1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Sun, 3 Sep 2023 14:13:06 +0200 Subject: [PATCH] Fix: Switch order of parameters --- src/Faker/Container/ContainerBuilder.php | 4 ++-- test/Faker/Extension/ContainerBuilderTest.php | 14 +++++++------- test/Faker/GeneratorTest.php | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Faker/Container/ContainerBuilder.php b/src/Faker/Container/ContainerBuilder.php index 012554713c..6a9c4747f0 100644 --- a/src/Faker/Container/ContainerBuilder.php +++ b/src/Faker/Container/ContainerBuilder.php @@ -29,7 +29,7 @@ final class ContainerBuilder * * @throws \InvalidArgumentException */ - public function add($value, string $name): self + public function add(string $name, $value): self { if (!is_string($value) && !is_callable($value) && !is_object($value)) { throw new \InvalidArgumentException(sprintf( @@ -71,7 +71,7 @@ public static function getDefault(): ContainerInterface $instance = new self(); foreach (self::defaultExtensions() as $id => $definition) { - $instance->add($definition, $id); + $instance->add($id, $definition); } return $instance->build(); diff --git a/test/Faker/Extension/ContainerBuilderTest.php b/test/Faker/Extension/ContainerBuilderTest.php index 02b64a2263..a86d81cde7 100644 --- a/test/Faker/Extension/ContainerBuilderTest.php +++ b/test/Faker/Extension/ContainerBuilderTest.php @@ -29,7 +29,7 @@ public function testAddRejectsInvalidValue($value): void ContainerBuilder::class, )); - $containerBuilder->add($value, 'foo'); + $containerBuilder->add('foo', $value); } /** @@ -71,7 +71,7 @@ public function testBuild(): void { $builder = new ContainerBuilder(); - $builder->add(File::class, 'foo'); + $builder->add('foo', File::class); $container = $builder->build(); @@ -82,8 +82,8 @@ public function testBuildWithDuplicates(): void { $builder = new ContainerBuilder(); - $builder->add(File::class, 'foo'); - $builder->add(File::class, 'foo'); + $builder->add('foo', File::class); + $builder->add('foo', File::class); $container = $builder->build(); @@ -94,7 +94,7 @@ public function testBuildWithObject(): void { $builder = new ContainerBuilder(); - $builder->add(new File(), 'foo'); + $builder->add('foo', new File()); $container = $builder->build(); @@ -105,9 +105,9 @@ public function testBuildWithCallable(): void { $builder = new ContainerBuilder(); - $builder->add(static function () { + $builder->add('foo', static function () { return new File(); - }, 'foo'); + }); $container = $builder->build(); diff --git a/test/Faker/GeneratorTest.php b/test/Faker/GeneratorTest.php index d8e7b11f7d..3adcf06534 100644 --- a/test/Faker/GeneratorTest.php +++ b/test/Faker/GeneratorTest.php @@ -135,7 +135,7 @@ public function testFormatTransfersArgumentsToFormatter(): void public function testFormatterCallsGenerator(): void { $builder = new ContainerBuilder(); - $builder->add(Blood::class, BloodExtension::class); + $builder->add(BloodExtension::class, Blood::class); $faker = new Generator($builder->build()); $output = $faker->format('bloodType');