From 4547227dcc089e3ec547cda6b2f4d5fd31b41af9 Mon Sep 17 00:00:00 2001 From: Eli Hovis Date: Tue, 6 Feb 2024 10:58:38 -0500 Subject: [PATCH 1/5] remove name sub-collision logging --- src/Model/ModelRegistry.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Model/ModelRegistry.php b/src/Model/ModelRegistry.php index 3f0defe08..a5318ea0b 100644 --- a/src/Model/ModelRegistry.php +++ b/src/Model/ModelRegistry.php @@ -146,16 +146,16 @@ private function generateModelName(Model $model): string ); $i = 1; while (\in_array($name, $names, true)) { - if (isset($this->registeredModelNames[$name])) { - $this->logger->info(sprintf('Can not assign a name for the model, the name "%s" has already been taken.', $name), [ - 'model' => $this->modelToArray($model), - 'taken_by' => $this->modelToArray($this->registeredModelNames[$name]), - ]); - } - ++$i; + $i++; $name = $base.$i; } + if($i > 1) { + $this->logger->info(sprintf('Can not assign a name for the model, the name "%s" is now being used %s times', $base, $i), [ + 'model' => $this->modelToArray($model), + 'taken_by' => $this->modelToArray($this->registeredModelNames[$base]), + ]); + } return $name; } From 103239e52d6ed0f37facb0e90aad6a406dae4209 Mon Sep 17 00:00:00 2001 From: Eli Hovis Date: Tue, 6 Feb 2024 11:42:14 -0500 Subject: [PATCH 2/5] Fix CI --- src/Model/ModelRegistry.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/ModelRegistry.php b/src/Model/ModelRegistry.php index a5318ea0b..3d329f7d9 100644 --- a/src/Model/ModelRegistry.php +++ b/src/Model/ModelRegistry.php @@ -146,11 +146,11 @@ private function generateModelName(Model $model): string ); $i = 1; while (\in_array($name, $names, true)) { - $i++; + ++$i; $name = $base.$i; } - if($i > 1) { + if ($i > 1) { $this->logger->info(sprintf('Can not assign a name for the model, the name "%s" is now being used %s times', $base, $i), [ 'model' => $this->modelToArray($model), 'taken_by' => $this->modelToArray($this->registeredModelNames[$base]), From 0f6cd102a95618fe7903b118a8d469d71e8456cc Mon Sep 17 00:00:00 2001 From: Eli Hovis Date: Tue, 6 Feb 2024 11:50:36 -0500 Subject: [PATCH 3/5] Fix failing tests --- src/Model/ModelRegistry.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Model/ModelRegistry.php b/src/Model/ModelRegistry.php index 3d329f7d9..5191e2dd0 100644 --- a/src/Model/ModelRegistry.php +++ b/src/Model/ModelRegistry.php @@ -151,10 +151,12 @@ private function generateModelName(Model $model): string } if ($i > 1) { - $this->logger->info(sprintf('Can not assign a name for the model, the name "%s" is now being used %s times', $base, $i), [ - 'model' => $this->modelToArray($model), - 'taken_by' => $this->modelToArray($this->registeredModelNames[$base]), - ]); + if (isset($this->registeredModelNames[$base])) { + $this->logger->info(sprintf('Can not assign a name for the model, the name "%s" is now being used %s times', $base, $i), [ + 'model' => $this->modelToArray($model), + 'taken_by' => $this->modelToArray($this->registeredModelNames[$base]), + ]); + } } return $name; } From 752875257a7a3dae4fd9a1fecd45ef972882ac20 Mon Sep 17 00:00:00 2001 From: Eli Hovis Date: Tue, 6 Feb 2024 12:16:09 -0500 Subject: [PATCH 4/5] Fix failing tests --- src/Model/ModelRegistry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/ModelRegistry.php b/src/Model/ModelRegistry.php index 5191e2dd0..cdbd4c9aa 100644 --- a/src/Model/ModelRegistry.php +++ b/src/Model/ModelRegistry.php @@ -152,7 +152,7 @@ private function generateModelName(Model $model): string if ($i > 1) { if (isset($this->registeredModelNames[$base])) { - $this->logger->info(sprintf('Can not assign a name for the model, the name "%s" is now being used %s times', $base, $i), [ + $this->logger->info(sprintf('Can not assign a name for the model, the name "%s" has already been taken.', $base), [ 'model' => $this->modelToArray($model), 'taken_by' => $this->modelToArray($this->registeredModelNames[$base]), ]); From e43665cb5e854932617a3ab1431fd59639015b2f Mon Sep 17 00:00:00 2001 From: Eli Hovis Date: Tue, 6 Feb 2024 12:16:19 -0500 Subject: [PATCH 5/5] Fix CI --- src/Model/ModelRegistry.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Model/ModelRegistry.php b/src/Model/ModelRegistry.php index cdbd4c9aa..98ac1fe93 100644 --- a/src/Model/ModelRegistry.php +++ b/src/Model/ModelRegistry.php @@ -158,6 +158,7 @@ private function generateModelName(Model $model): string ]); } } + return $name; }