From 88bb072c9b2a08d362179b35605dddc94d28b360 Mon Sep 17 00:00:00 2001 From: Bram Ceulemans Date: Tue, 18 Jan 2022 11:43:13 +0100 Subject: [PATCH] Fix UniqueGenerator not storing previously generated values when calling ->ext() method --- src/Faker/UniqueGenerator.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Faker/UniqueGenerator.php b/src/Faker/UniqueGenerator.php index daf0d85e9c..58ed8cbb9c 100644 --- a/src/Faker/UniqueGenerator.php +++ b/src/Faker/UniqueGenerator.php @@ -29,18 +29,20 @@ class UniqueGenerator protected $uniques = []; /** - * @param Extension|Generator $generator - * @param int $maxRetries + * @param Extension|Generator $generator + * @param int $maxRetries + * @param array> $uniques */ - public function __construct($generator, $maxRetries = 10000) + public function __construct($generator, $maxRetries = 10000, & $uniques = []) { $this->generator = $generator; $this->maxRetries = $maxRetries; + $this->uniques = &$uniques; } public function ext(string $id) { - return new self($this->generator->ext($id), $this->maxRetries); + return new self($this->generator->ext($id), $this->maxRetries, $this->uniques); } /**