From bd571f20284fa84768de126733d92d036ba6ad23 Mon Sep 17 00:00:00 2001 From: PrinsFrank Date: Mon, 10 Apr 2023 11:18:41 +0200 Subject: [PATCH] Don't mark enum keys as deprecated when their value changed --- dev/SpecUpdater.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dev/SpecUpdater.php b/dev/SpecUpdater.php index 7360ef8d..43b1feac 100644 --- a/dev/SpecUpdater.php +++ b/dev/SpecUpdater.php @@ -134,10 +134,15 @@ public static function update(Event $event): void $enumCases[] = new EnumCase($name, $value); } - $existingValues = array_map(static function (\BackedEnum $backedEnum) { - return $backedEnum->value; - }, $specFQN::cases()); - foreach (array_diff($existingValues, $nameValuePairs) as $deprecatedValue) { + $existingValues = []; + foreach ($specFQN::cases() as $existingValue) { + $existingValues[$existingValue->name] = $existingValue->value; + } + foreach (array_diff_key($existingValues, $nameValuePairs) as $deprecatedKey => $deprecatedValue) { + if (array_key_exists($deprecatedKey, $existingValues)) { + continue; + } + $enumCases[] = new EnumCase($specFQN::from($deprecatedValue)->name, $deprecatedValue, true); }